Skip to content

Commit

Permalink
csv lib compat in ruby 1.9.x
Browse files Browse the repository at this point in the history
fastercsv is not supported in 1.9, instead csv in the stdlib has been
modified to be api compatible with fastercsv. in this first step, we
alias CSV to FasterCSV when running under 1.9. This allows 1.8.7 to
continue working with no changes.

Change-Id: I34c3a9031b6f4946380510e4833203e29a05073a
Reviewed-on: https://gerrit.instructure.com/5835
Tested-by: Hudson <[email protected]>
Reviewed-by: Zach Wily <[email protected]>
  • Loading branch information
codekitchen committed Oct 12, 2011
1 parent e07e64b commit 1fe1b1a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ gem 'compass', '0.11.5'
gem 'daemons', '1.1.0'
gem 'diff-lcs', '1.1.2', :require => 'diff/lcs'
gem 'erubis', '2.7.0'
gem 'fastercsv', '1.5.3'
gem 'hairtrigger', '0.1.11'
gem 'haml', '3.1.2'
gem 'hashery', '1.3.0', :require => 'hashery/dictionary'
Expand Down Expand Up @@ -105,6 +104,10 @@ if WINDOWS
end
end

if !ONE_NINE
gem 'fastercsv', '1.5.3'
end

# Non-standard Canvas extension to Bundler behavior -- load the Gemfiles from
# plugins.
Dir[File.join(File.dirname(__FILE__),'vendor/plugins/*/Gemfile')].each do |g|
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/ruby_version_compat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 1.9 has a built-in equivalent to fastercsv
if RUBY_VERSION > "1.9."
require 'csv'
FasterCSV = CSV
else
require 'fastercsv'
end
1 change: 0 additions & 1 deletion lib/ext/array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#

class Array
require "fastercsv"
def to_csv(options = {})
if all? { |e| e.respond_to?(:to_row) }
header_row = first.export_columns(options[:format]).to_csv
Expand Down
1 change: 0 additions & 1 deletion lib/gradebook_csv_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#

# This is used for the GradebookImporter
require 'fastercsv'
require 'ostruct'

class CSVParser
Expand Down
1 change: 0 additions & 1 deletion lib/sis/csv/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
#

require 'faster_csv'
require 'zip/zip'

module SIS
Expand Down
2 changes: 0 additions & 2 deletions lib/tasks/rspec.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9

# Don't load rspec if running "rake gems:*"
unless ARGV.any? {|a| a =~ /\Agems/}

Expand Down

0 comments on commit 1fe1b1a

Please sign in to comment.