Class: AdLocalize::Runner
- Inherits:
-
Object
- Object
- AdLocalize::Runner
- Defined in:
- lib/ad_localize/runner.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run(args = ARGV) ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
5 6 7 |
# File 'lib/ad_localize/runner.rb', line 5 def initialize = OptionHandler.parse end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/ad_localize/runner.rb', line 3 def end |
Instance Method Details
#run(args = ARGV) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ad_localize/runner.rb', line 9 def run(args = ARGV) LOGGER.log(:info, :black, "OPTIONS : #{options}") input_files = (args + [.dig(:drive_key)]).compact # drive_key can be nil if input_files.length.zero? LOGGER.log(:error, :red, "No CSV to parse. Use option -h to see how to use this script") else file_to_parse = args.first LOGGER.log(:warn, :yellow, "Only one CSV can be treated - the priority goes to #{file_to_parse}") if input_files.length > 1 if args.empty? [:drive_file] = CsvFileManager.download_from_drive(.dig(:drive_key), .dig(:sheet_id)) file_to_parse = .dig(:drive_file) end CsvFileManager.csv?(file_to_parse) ? export(file_to_parse) : LOGGER.log(:error, :red, "#{file_to_parse} is not a csv") CsvFileManager.delete_drive_file([:drive_file]) if [:drive_file] end end |