Skip to content

Commit

Permalink
respect the :file field mapping's split config (#1019)
Browse files Browse the repository at this point in the history
* respect the :file field mapping's split config

* handle other possible split value types
  • Loading branch information
bkiahstroud authored Feb 27, 2025
1 parent 2011e39 commit daa2591
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/parsers/bulkrax/csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,16 @@ def file_paths
file_mapping = Bulkrax.field_mappings.dig(self.class.to_s, 'file', :from)&.first&.to_sym || :file
next if r[file_mapping].blank?

r[file_mapping].split(Bulkrax.multi_value_element_split_on).map do |f|
split_value = Bulkrax.field_mappings.dig(self.class.to_s, :file, :split)
split_pattern = case split_value
when Regexp
split_value
when String
Regexp.new(split_value)
else
Bulkrax.multi_value_element_split_on
end
r[file_mapping].split(split_pattern).map do |f|
file = File.join(path_to_files, f.tr(' ', '_'))
if File.exist?(file) # rubocop:disable Style/GuardClause
file
Expand Down

0 comments on commit daa2591

Please sign in to comment.