From a2443bdcf9f0c57c6623524fa5f85cd0d3a8ed29 Mon Sep 17 00:00:00 2001 From: jeg2 Date: Tue, 25 Dec 2007 05:14:04 +0000 Subject: * lib/csv.rb: Fixed test failures caused by changes to Ruby. * test/csv/tc_serialization, test/csv/tc_csv_parsing, test/csv/tc_features: Fixed test failures caused by changes to Ruby. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/csv.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/csv.rb') diff --git a/lib/csv.rb b/lib/csv.rb index a37bc700b2..b12142e50a 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -187,10 +187,12 @@ class CSV @header_row = header_row # handle extra headers or fields - @row = if headers.size > fields.size - headers.zip(fields) - else - fields.zip(headers).map { |pair| pair.reverse } + larger, smaller, transform = headers.size > fields.size ? + [headers, fields, :to_a] : + [fields, headers, :reverse] + @row = Array.new + larger.each_with_index do |e, i| + @row << [e, smaller[i]].send(transform) end end @@ -1812,7 +1814,8 @@ class CSV # see if we are converting headers or fields converters = headers ? @header_converters : @converters - fields.enum_for(:each_with_index).map do |field, index| # map_with_index + converted = Array.new + fields.each_with_index do |field, index| converters.each do |converter| field = if converter.arity == 1 # straight field converter converter[field] @@ -1822,8 +1825,9 @@ class CSV end break unless field.is_a? String # short-curcuit pipeline for speed end - field # return final state of each field, converted or original + converted << field # final state of each field, converted or original end + converted end # -- cgit v1.2.3