Skip to content

Commit

Permalink
Fix status code loading in 1.8.7 by using FasterCSV.
Browse files Browse the repository at this point in the history
The CSV implementation in 1.9 is actually derived from FasterCSV so this is
probably the best way to implement backwards compatibility.
  • Loading branch information
Manfred committed Oct 18, 2012
1 parent 524f555 commit eede04d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions buckaroo-ideal.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ Gem::Specification.new do |gem|

gem.add_dependency 'activesupport'
gem.add_dependency 'transliterator'

if RUBY_VERSION < "1.9"
gem.add_dependency 'fastercsv'
end
end
10 changes: 8 additions & 2 deletions lib/buckaroo-ideal/status.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'csv'

module Buckaroo
module Ideal
class Status
Expand Down Expand Up @@ -27,6 +25,14 @@ class UnknownStatusCode < StandardError; end

CSV_FILE = File.expand_path('../../../files/statuscodes.csv', __FILE__)

if RUBY_VERSION < "1.9"
require 'fastercsv'
CSV = ::FasterCSV
else
require 'csv'
CSV = ::CSV
end

attr_reader :code, :message

def self.status_codes(csv_file = CSV_FILE)
Expand Down

0 comments on commit eede04d

Please sign in to comment.