Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Commit

Permalink
updating to_csv for ruby 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Croak committed Feb 1, 2011
1 parent 1eb2009 commit bb699f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 0 additions & 6 deletions vendor/plugins/to_csv/init.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
if RUBY_VERSION >= "1.9.0"
require 'csv'
else
require 'fastercsv'
end

require 'to_csv'
10 changes: 9 additions & 1 deletion vendor/plugins/to_csv/lib/to_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ def to_csv(options = {})

return '' if columns.empty?

output = CSV.generate do |csv|
this_csv = if RUBY_VERSION >= "1.9.0"
require 'csv'
CSV
else
require 'fastercsv'
FasterCSV
end

output = this_csv.generate do |csv|
csv << columns.map { |column| klass.human_attribute_name(column) } unless options[:headers] == false
self.each do |item|
csv << columns.collect { |column| item.send(column) }
Expand Down

0 comments on commit bb699f5

Please sign in to comment.