Class: Locraft::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/locraft/extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ Extractor

Returns a new instance of Extractor.



7
8
9
# File 'lib/locraft/extractor.rb', line 7

def initialize(config_file)
  @config = Config.load_from(config_file)
end

Instance Method Details

#extractObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/locraft/extractor.rb', line 11

def extract
  csv = GoogleDriveWrapper.new(@config).export_worksheet_csv
  csv_parser = CSVParser.new(@config)
  localizations_hash = csv_parser.parse_csv(csv)
  if localizations_hash[@config.default_lang].nil?
    warn 'extract ERROR: no localizations given'
  else
    generate_strings(localizations_hash)
  end
end

#generate_strings(localizations_hash) ⇒ Object



22
23
24
25
26
# File 'lib/locraft/extractor.rb', line 22

def generate_strings(localizations_hash)
  @config.strings_generators.each do |generator|
    generator.generate(localizations_hash)
  end
end