1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/csv.rb: Don't attempt to convert nil headers.

Reported by Skye Shaw



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
jeg2 2014-04-01 14:35:03 +00:00
parent 86034eafb2
commit 7c4d4e1eb2
3 changed files with 13 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Tue Apr 1 11:34:04 2014 James Edward Gray II <james@graysoftinc.com>
* lib/csv.rb: Don't attempt to convert nil headers.
Reported by Skye Shaw
Tue Apr 1 17:29:35 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/config_files.rb (ConfigFiles.download): show failed URI.

View file

@ -2168,6 +2168,7 @@ class CSV
fields.map.with_index do |field, index|
converters.each do |converter|
break if field.nil?
field = if converter.arity == 1 # straight field converter
converter[field]
else # FieldInfo converter

View file

@ -223,6 +223,13 @@ class TestCSV::Headers < TestCSV
assert_equal([:one, :two_three], csv.headers)
end
def test_builtin_converters_with_blank_header
csv = CSV.parse( "one,,three", headers: true,
return_headers: true,
header_converters: [:downcase, :symbol] )
assert_equal([:one, nil, :three], csv.headers)
end
def test_custom_converter
converter = lambda { |header| header.tr(" ", "_") }
csv = CSV.parse( "One,TWO Three",