Project

General

Profile

Bug #5070 ยป csv.patch

marcandre (Marc-Andre Lafortune), 07/22/2011 04:23 AM

View differences:

lib/csv.rb
io.seek(0, IO::SEEK_END)
args.unshift(io)
else
encoding = args.last.is_a?(Hash) ? args.last.delete(:encoding) : nil
encoding = (args[-1] = args[-1].dup).delete(:encoding) if args.last.is_a?(Hash)
str = ""
str.encode!(encoding) if encoding
args.unshift(str)
test/csv/test_interface.rb
assert_equal(STDOUT, CSV.instance.instance_eval { @io })
assert_equal(STDOUT, CSV { |new_csv| new_csv.instance_eval { @io } })
end
def test_options_are_not_modified
opt = {}.freeze
assert_nothing_raised { CSV.foreach(@path, opt) }
assert_nothing_raised { CSV.open(@path, opt){} }
assert_nothing_raised { CSV.parse("", opt) }
assert_nothing_raised { CSV.parse_line("", opt) }
assert_nothing_raised { CSV.read(@path, opt) }
assert_nothing_raised { CSV.readlines(@path, opt) }
assert_nothing_raised { CSV.table(@path, opt) }
assert_nothing_raised { CSV.generate(opt){} }
assert_nothing_raised { CSV.generate_line([], opt) }
assert_nothing_raised { CSV.filter("", "", opt){} }
assert_nothing_raised { CSV.instance("", opt) }
end
end
    (1-1/1)