Bug #2681
closedsome behavior changes of lib/csv.rb between 1.8 and 1.9
Description
=begin
Hi jeg2, or anyone who knows the implementation of FasterCSV,
I'm now checking for ruby trunk to pass rubyspec. Are these behavior
changes of lib/csv.rb intended or bug?
- CSV.generate
$ ruby18 -rcsv -e 'w = CSV.generate("foo18.csv"); w << [1, 2, 3]; w.close'
$ cat foo18.csv
1,2,3
$ ruby19 -rcsv -e 'w = CSV.generate("foo19.csv"); w << [1, 2, 3]; w.close'
/home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1231:in
generate': no block given (yield) (LocalJumpError) from -e:1:in
'
There is the comment of csv.rb:
The old CSV's Reader and Writer classes have been dropped.
CSV::generate() is different from the old method.
They mean this change, don't they?
- CSV.generate_line
$ ruby18 -rcsv -e 'p CSV.generate_line([])'
""
$ ruby19 -rcsv -e 'p CSV.generate_line([])'
"\n"
- CSV.generate_line (2)
$ ruby18 -rcsv -e 'p CSV::generate_line(["foo", "bar"], ?;)'
"foo;bar"
$ ruby19 -rcsv -e 'p CSV::generate_line(["foo", "bar"], ?;)'
/home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1249:in merge': can't convert String into Hash (TypeError) from /home/mame/work/ruby19/local/lib/ruby/1.9.1/csv.rb:1249:in
generate_line'
from -e:1:in `'
- CSV.parse
$ ruby18 -rcsv -ve 'p CSV.parse "\nfoo"'
[[nil], ["foo"]]
$ ruby19 -rcsv -ve 'p CSV.parse "\nfoo"'
[[], ["foo"]]
- CSV.parse_line
$ ruby18 -rcsv -ve 'p CSV.parse_line ""'
[nil]
$ ruby19 -rcsv -ve 'p CSV.parse_line ""'
nil
- CSV.parse_line (2)
$ ruby18 -rcsv -ve 'p CSV.parse_line "\nfoo"'
[nil]
$ ruby19 -rcsv -ve 'p CSV.parse_line "\nfoo"'
[]
Thanks,
--
Yusuke ENDOH mame@tsg.ne.jp
=end