Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make it work with Ruby 1.9

  • Loading branch information...
commit 1096a4a8d7e98c203a7c5f8d8137c4411706d0c9 1 parent ed22c1f
@harrigan harrigan authored
View
1  Rakefile
@@ -13,7 +13,6 @@ begin
gem.homepage = "http://github.com/darwin/csv2json"
gem.authors = ["Antonin Hildebrand", "Rafael Souza"]
gem.add_dependency "json"
- gem.add_dependency "fastercsv"
gem.add_development_dependency "shoulda", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
View
2  bin/csv2json
@@ -74,7 +74,7 @@ module CSV2JSONRunner
if ARGV.size > 0
IN = File.open(ARGV[0], "r")
else
- IN = StringIO.new($stdin.read) # cannot be just $stdin.clone because FasterCSV is seeking in file :-(
+ IN = StringIO.new($stdin.read) # cannot be just $stdin.clone because CSV is seeking in file :-(
end
# run the command
View
2  bin/json2csv
@@ -62,7 +62,7 @@ module JSON2CSVRunner
if ARGV.size > 0
IN = File.read(ARGV[0])
else
- IN = StringIO.new($stdin.read) # cannot be just $stdin.clone because FasterCSV is seeking in file :-(
+ IN = STDIN.read
end
# run the command
View
3  csv2json.gemspec
@@ -67,18 +67,15 @@ Gem::Specification.new do |s|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<json>, [">= 0"])
- s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
s.add_runtime_dependency(%q<orderedhash>, [">= 0"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
else
s.add_dependency(%q<json>, [">= 0"])
- s.add_dependency(%q<fastercsv>, [">= 0"])
s.add_dependency(%q<orderedhash>, [">= 0"])
s.add_dependency(%q<shoulda>, [">= 0"])
end
else
s.add_dependency(%q<json>, [">= 0"])
- s.add_dependency(%q<fastercsv>, [">= 0"])
s.add_dependency(%q<orderedhash>, [">= 0"])
s.add_dependency(%q<shoulda>, [">= 0"])
end
View
4 lib/csv2json.rb
@@ -1,5 +1,5 @@
require 'rubygems'
-require 'fastercsv'
+require 'csv'
require 'json'
require 'orderedhash'
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'csv2json-version.rb')
@@ -16,7 +16,7 @@ def convert(val)
def parse(input, output, headers=nil, csvOptions={}, gemOptions={})
result = Array.new
- FasterCSV.new(input, csvOptions).each do |row|
+ CSV.new(input, csvOptions).each do |row|
# treat first row as headers if the caller didn't provide them
unless headers
headers = row
View
4 lib/json2csv.rb
@@ -1,5 +1,5 @@
require 'rubygems'
-require 'fastercsv'
+require 'csv'
require 'json'
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'csv2json-version.rb')
@@ -12,7 +12,7 @@ def parse(input, output, headers=nil, csvOptions=nil)
headers = json[0].keys
end
- outputCSV = FasterCSV.generate(csvOptions) do |csv|
+ outputCSV = CSV.generate(csvOptions) do |csv|
csv << headers
json.each do |obj|
View
2  test/test_csv2json.rb
@@ -19,7 +19,7 @@ class TestCsv2json < Test::Unit::TestCase
template = File.read(json_template)
output.pos = 0
- assert "Content doesn't match", template == output.read
+ assert JSON.parse(template) == JSON.parse(output.read), "Content doesn't match"
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.