Thursday, March 6, 2008

FasterCSV API Shim for 1.9

FasterCSV has become csv.rb in Ruby 1.9. This is awesome, but it does change the names of the constants, which means your code will not run without some modification on 1.9

Ruport wants to work peacefully on both 1.8 and 1.9 without too much duplication of effort, so here's the hack JEG2 and I came up with to get things running (defined at the top level).
if RUBY_VERSION > "1.9"    
require "csv"
unless defined? FCSV
class Object
FCSV = CSV
alias_method :FCSV, :CSV
end
end
else
require "fastercsv"
end
If you're using FCSV in other work outside of Ruport, you may find this shim useful for compatibility.

This marks the beginning of the attempt to make Ruport fully 1.9 compatible. Keep an eye on trunk in the coming weeks, and please help test!

No comments: