Class: Tagger::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/tagger/cli.rb

Instance Method Summary collapse

Instance Method Details

#generate(url) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tagger/cli.rb', line 6

def generate(url)
  puts "Generate AnalyticsEvent.#{options[:platform] == 'ios' ? 'swift' : 'kotlin'}"

  # Download as CSV
  downloader = Tagger::Downloader.new(url)
  csv = downloader.download()

  # Parse CSV
  raw_file = CSV.parse(csv, headers: true)
  events = raw_file.map { |row|
    Tagger::Event.new(name: row[1], firebase: row[2].downcase, appsflyer: row[3].downcase)
  }.select { |event|
    event.valid?
  }

  generator = Tagger::Generator.new(events, options[:platform].to_sym)
  generator.generate(options[:out])
end