From 13394a723551ce319e0bb4ca6a8a24cb682ffc72 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sun, 28 Aug 2011 00:34:47 -0700 Subject: [PATCH] Remove JSON dependency --- gems.gemspec | 1 - lib/gems/client.rb | 5 ++--- spec/fixtures/coulda.json | 1 - spec/fixtures/script_helpers.yaml | 17 +++++++++++++++++ spec/gems/client_spec.rb | 10 +++++----- 5 files changed, 24 insertions(+), 10 deletions(-) delete mode 100644 spec/fixtures/coulda.json create mode 100644 spec/fixtures/script_helpers.yaml diff --git a/gems.gemspec b/gems.gemspec index 6c1fd82..8ca6c47 100644 --- a/gems.gemspec +++ b/gems.gemspec @@ -15,7 +15,6 @@ Gem::Specification.new do |gem| gem.homepage = 'https://github.com/rubygems/gems' gem.name = 'gems' gem.require_paths = ['lib'] - gem.required_ruby_version = '>= 1.9' gem.summary = gem.description gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") gem.version = Gems::VERSION diff --git a/lib/gems/client.rb b/lib/gems/client.rb index 9da6e6b..19bc560 100644 --- a/lib/gems/client.rb +++ b/lib/gems/client.rb @@ -1,7 +1,6 @@ require 'date' require 'gems/configuration' require 'gems/request' -require 'json' require 'yaml' module Gems @@ -48,8 +47,8 @@ def search(query) # @example # Gems.versions 'coulda' def versions(gem_name) - response = get("/api/v1/versions/#{gem_name}.json") - JSON.parse(response) + response = get("/api/v1/versions/#{gem_name}.yaml") + YAML.load(response) end # Returns the total number of downloads for a particular gem diff --git a/spec/fixtures/coulda.json b/spec/fixtures/coulda.json deleted file mode 100644 index d608127..0000000 --- a/spec/fixtures/coulda.json +++ /dev/null @@ -1 +0,0 @@ -[{"number":"0.6.3","built_at":"2010-12-23T05:00:00Z","prerelease":false,"downloads_count":808,"summary":"Test::Unit-based acceptance testing DSL","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.6.1","built_at":"2010-11-20T05:00:00Z","prerelease":false,"downloads_count":289,"summary":"Test::Unit-based acceptance testing DSL","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.6.0","built_at":"2010-10-29T04:00:00Z","prerelease":false,"downloads_count":281,"summary":"Test::Unit-based acceptance testing DSL","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.5.5","built_at":"2010-09-10T04:00:00Z","prerelease":false,"downloads_count":230,"summary":"Test::Unit-based acceptance testing DSL","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.5.3","built_at":"2009-12-08T05:00:00Z","prerelease":false,"downloads_count":741,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.5.2","built_at":"2009-12-06T05:00:00Z","prerelease":false,"downloads_count":387,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.5.1","built_at":"2009-12-04T05:00:00Z","prerelease":false,"downloads_count":365,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.5.0","built_at":"2009-12-04T05:00:00Z","prerelease":false,"downloads_count":365,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.7","built_at":"2009-11-30T05:00:00Z","prerelease":false,"downloads_count":365,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.6","built_at":"2009-11-30T05:00:00Z","prerelease":false,"downloads_count":362,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.5","built_at":"2009-11-26T05:00:00Z","prerelease":false,"downloads_count":367,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.4","built_at":"2009-11-24T05:00:00Z","prerelease":false,"downloads_count":366,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.3","built_at":"2009-11-24T05:00:00Z","prerelease":false,"downloads_count":363,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.2","built_at":"2009-11-24T05:00:00Z","prerelease":false,"downloads_count":363,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.1","built_at":"2009-11-24T05:00:00Z","prerelease":false,"downloads_count":367,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.4.0","built_at":"2009-11-23T05:00:00Z","prerelease":false,"downloads_count":369,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.3.1","built_at":"2009-09-23T07:00:00Z","prerelease":false,"downloads_count":398,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.3.0","built_at":"2009-09-23T07:00:00Z","prerelease":false,"downloads_count":346,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"},{"number":"0.2.0","built_at":"2009-09-12T07:00:00Z","prerelease":false,"downloads_count":347,"summary":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","description":"Behaviour Driven Development derived from Cucumber but as an internal DSL with methods for reuse","authors":"Evan David Light","platform":"ruby"}] \ No newline at end of file diff --git a/spec/fixtures/script_helpers.yaml b/spec/fixtures/script_helpers.yaml new file mode 100644 index 0000000..5c03513 --- /dev/null +++ b/spec/fixtures/script_helpers.yaml @@ -0,0 +1,17 @@ +--- +- built_at: "2011-07-11T07:00:00Z" + number: 0.1.0 + prerelease: false + authors: Mike Stone + description: A Rails 3 gem that allows easy inlining of css and JavaScript + summary: Script Helpers + downloads_count: 0 + platform: ruby +- built_at: "2011-07-11T07:00:00Z" + number: 0.0.1 + prerelease: false + authors: Mike Stone + description: A Rails 3 gem that allows easy inlining of css and JavaScript + summary: Script Helpers + downloads_count: 0 + platform: ruby diff --git a/spec/gems/client_spec.rb b/spec/gems/client_spec.rb index 3618452..31b69d0 100644 --- a/spec/gems/client_spec.rb +++ b/spec/gems/client_spec.rb @@ -37,15 +37,15 @@ describe ".versions" do before do - stub_get("/api/v1/versions/coulda.json"). - to_return(:body => fixture("coulda.json")) + stub_get("/api/v1/versions/script_helpers.yaml"). + to_return(:body => fixture("script_helpers.yaml")) end it "should return an array of gem version details" do - versions = Gems.versions 'coulda' - a_get("/api/v1/versions/coulda.json"). + versions = Gems.versions 'script_helpers' + a_get("/api/v1/versions/script_helpers.yaml"). should have_been_made - versions.first['number'].should == '0.6.3' + versions.first['number'].should == '0.1.0' end end