Top Level Namespace

Defined Under Namespace

Modules: ETL, HttpTools Classes: ActiveRecordResolver, FlatFileResolver, IncrementalCacheSQLResolver, MySqlStreamer, Object, SQLResolver, Time

Constant Summary collapse

CSV =
FasterCSV

Instance Method Summary collapse

Instance Method Details

#executeObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/etl/commands/etl.rb', line 32

def execute
  opts = GetoptLong.new(
    [ '--version', '-v', GetoptLong::NO_ARGUMENT],
    [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
    [ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ],
    [ '--limit', '-l', GetoptLong::REQUIRED_ARGUMENT ],
    [ '--offset', '-o', GetoptLong::REQUIRED_ARGUMENT],
    [ '--newlog', '-n', GetoptLong::NO_ARGUMENT ],
    [ '--skip-bulk-import', '-s', GetoptLong::NO_ARGUMENT ],
    [ '--read-locally', GetoptLong::NO_ARGUMENT],
    [ '--rails-root', GetoptLong::REQUIRED_ARGUMENT]
  )
  
  options = {}
  opts.each do |opt, arg|
    case opt
    when '--version'
      puts "ActiveWarehouse ETL version #{ETL::VERSION::STRING}"
      return
    when '--help'
      usage
      return
    when '--config'
      options[:config] = arg
    when '--limit'
      options[:limit] = arg.to_i
    when '--offset'
      options[:offset] = arg.to_i
    when '--newlog'
      options[:newlog] = true
    when '--skip-bulk-import'
      puts "skip bulk import enabled"
      options[:skip_bulk_import] = true
    when '--read-locally'
      puts "read locally enabled"
      options[:read_locally] = true
    when '--rails-root'
      options[:rails_root] = arg
      puts "rails root set to #{options[:rails_root]}"
    end
  end

  if ARGV.length < 1
    usage
  else
    puts "Starting ETL process"

    ETL::Engine.init(options)
    ARGV.each do |f|
      ETL::Engine.realtime_activity = true
      ETL::Engine.process(f)
      exit(ETL::Engine.exit_code) if ETL::Engine.exit_code
    end
  
    puts "ETL process complete\n\n"
  end
end

#usageObject

Print a usage statement



28
29
30
# File 'lib/etl/commands/etl.rb', line 28

def usage #:nodoc:
  puts "Usage: etl file [file file ...]" # TODO: add the command line options
end