Skip to content

Commit e4753a4

Browse files
committed
Use case-insensitive comparison when ignoring fields
1 parent 1e1b294 commit e4753a4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/csv-diff/csv_diff.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ def diff_warnings
138138
# Given two sets of field names, determines the common set of fields present
139139
# in both, on which members can be diffed.
140140
def get_diff_fields(left_fields, right_fields, options)
141-
ignore_fields = (options[:ignore_fields] || []).map do |f|
142-
f.is_a?(Fixnum) ? right_fields[f] : f
141+
ignore_fields = options.fetch(:ignore_fields, [])
142+
ignore_fields = [ignore_fields] unless ignore_fields.is_a?(Array)
143+
ignore_fields.map! do |f|
144+
(f.is_a?(Fixnum) ? right_fields[f] : f).upcase
143145
end
144146
diff_fields = []
145147
if options[:diff_common_fields_only]
@@ -151,7 +153,7 @@ def get_diff_fields(left_fields, right_fields, options)
151153
end
152154
end
153155
else
154-
diff_fields = (right_fields + left_fields).uniq.reject{ |fld| ignore_fields.include?(fld) }
156+
diff_fields = (right_fields + left_fields).uniq.reject{ |fld| ignore_fields.include?(fld.upcase) }
155157
end
156158
diff_fields
157159
end

0 commit comments

Comments
 (0)