Class: Chouette::Exporter

Inherits:
Object
  • Object
show all
Includes:
CommandLineSupport
Defined in:
app/models/chouette/exporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CommandLineSupport

#available_loggers, #execute!, #logger, #max_output_length

Constructor Details

#initialize(schema) ⇒ Exporter

Returns a new instance of Exporter.



5
6
7
# File 'app/models/chouette/exporter.rb', line 5

def initialize(schema)
  @schema = schema
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



3
4
5
# File 'app/models/chouette/exporter.rb', line 3

def schema
  @schema
end

Instance Method Details

#chouette_commandObject



9
10
11
# File 'app/models/chouette/exporter.rb', line 9

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

#export(file, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/chouette/exporter.rb', line 13

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