aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/exporter.rb
blob: df85a9dde5a1408b514fd905ccc4bc65eb51c644 (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
class Chouette::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