aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/exporter.rb
blob: 98cab7269ee576275111233168cfe9c5318ff51d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Chouette
  class Exporter

    attr_reader :schema

    def initialize(schema)
      @schema = schema
    end

    def chouette_command
      @chouette_command ||= Chouette::Command.new(:schema => schema)
    end

    def export(file, options = {})
      options = {
        :format => :neptune
      }.merge(options)

      command_options = {
        :c => "export", 
        :o => "line", 
        :format => options.delete(:format).to_s.upcase, 
        :output_file => File.expand_path(file), 
        :optimize_memory => true
      }.merge(options)

      logger.info "Export #{file} in schema #{schema}"
      chouette_command.run! command_options
    end

    include Chouette::CommandLineSupport

  end
end