Class: AdLocalize::Parsers::CSVParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/parsers/csv_parser.rb

Constant Summary collapse

COMMENT_KEY_COLUMN_IDENTIFIER =
'comment'.freeze
CSV_WORDING_KEYS_COLUMN =
'key'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(key_parser: nil) ⇒ CSVParser

Returns a new instance of CSVParser.



8
9
10
# File 'lib/ad_localize/parsers/csv_parser.rb', line 8

def initialize(key_parser: nil)
  @key_parser = key_parser.presence || KeyParser.new
end

Instance Method Details

#call(csv_path:, export_request:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ad_localize/parsers/csv_parser.rb', line 12

def call(csv_path:, export_request:)
  locales = find_locales(csv_path: csv_path, export_request: export_request)
  LOGGER.debug("#{csv_path} - locales : #{locales.to_sentence}")
  return if locales.blank?

  keys = find_keys(csv_path: csv_path)
  wording = build_wording(
    csv_path: csv_path,
    locales: locales,
    keys: keys,
    export_request: export_request
  )
  wording
end