Class: AdLocalize::Interactors::ParseCSVFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/interactors/parse_csv_files.rb

Instance Method Summary collapse

Constructor Details

#initializeParseCSVFiles

Returns a new instance of ParseCSVFiles.



5
6
7
# File 'lib/ad_localize/interactors/parse_csv_files.rb', line 5

def initialize
  @csv_parser = Parsers::CSVParser.new
end

Instance Method Details

#call(export_request:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ad_localize/interactors/parse_csv_files.rb', line 9

def call(export_request:)
  csv_paths = export_request.all_csv_paths
  LOGGER.debug("Will parse #{csv_paths.size} csv files")
  wordings = csv_paths.filter_map do |csv_path|
    @csv_parser.call(csv_path: csv_path, export_request: export_request)
  end
  LOGGER.debug("#{wordings.size} wording contents detected")
  return if wordings.blank?

  MergeWordings.new.call(wordings: wordings, merge_policy: export_request.merge_policy)
end