Skip to content

Commit daa2591

Browse files
authored
respect the :file field mapping's split config (#1019)
* respect the :file field mapping's split config * handle other possible split value types
1 parent 2011e39 commit daa2591

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/parsers/bulkrax/csv_parser.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,16 @@ def file_paths
341341
file_mapping = Bulkrax.field_mappings.dig(self.class.to_s, 'file', :from)&.first&.to_sym || :file
342342
next if r[file_mapping].blank?
343343

344-
r[file_mapping].split(Bulkrax.multi_value_element_split_on).map do |f|
344+
split_value = Bulkrax.field_mappings.dig(self.class.to_s, :file, :split)
345+
split_pattern = case split_value
346+
when Regexp
347+
split_value
348+
when String
349+
Regexp.new(split_value)
350+
else
351+
Bulkrax.multi_value_element_split_on
352+
end
353+
r[file_mapping].split(split_pattern).map do |f|
345354
file = File.join(path_to_files, f.tr(' ', '_'))
346355
if File.exist?(file) # rubocop:disable Style/GuardClause
347356
file

0 commit comments

Comments
 (0)