Created
January 6, 2010 16:15
-
-
Save jhsu/270381 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 88db6d4483a33cc67d0f23f0383c7431a1a3b254 Mon Sep 17 00:00:00 2001 | |
| From: Joseph Hsu <jhsu.x1@gmail.com> | |
| Date: Wed, 6 Jan 2010 11:14:47 -0500 | |
| Subject: [PATCH] add version_downloads to api | |
| --- | |
| app/models/rubygem.rb | 15 ++++++++------- | |
| app/views/pages/api_docs.html.erb | 1 + | |
| test/unit/rubygem_test.rb | 1 + | |
| 3 files changed, 10 insertions(+), 7 deletions(-) | |
| diff --git a/app/models/rubygem.rb b/app/models/rubygem.rb | |
| index 95feba0..f865f41 100644 | |
| --- a/app/models/rubygem.rb | |
| +++ b/app/models/rubygem.rb | |
| @@ -77,13 +77,14 @@ class Rubygem < ActiveRecord::Base | |
| def payload(version = versions.latest, host_with_port = HOST) | |
| { | |
| - :name => name, | |
| - :downloads => downloads, | |
| - :version => version.number, | |
| - :authors => version.authors, | |
| - :info => version.info, | |
| - 'project_uri' => "http://#{host_with_port}/gems/#{name}", | |
| - 'gem_uri' => "http://#{host_with_port}/gems/#{version.full_name}.gem" | |
| + :name => name, | |
| + :downloads => downloads, | |
| + :version => version.number, | |
| + :version_downloads => version.downloads_count, | |
| + :authors => version.authors, | |
| + :info => version.info, | |
| + :project_uri => "http://#{host_with_port}/gems/#{name}", | |
| + :gem_uri => "http://#{host_with_port}/gems/#{version.full_name}.gem" | |
| } | |
| end | |
| diff --git a/app/views/pages/api_docs.html.erb b/app/views/pages/api_docs.html.erb | |
| index 0c4b78c..bd19d8c 100644 | |
| --- a/app/views/pages/api_docs.html.erb | |
| +++ b/app/views/pages/api_docs.html.erb | |
| @@ -25,6 +25,7 @@ The API is a work in progress, and <%= link_to "can use your help!", "http://git | |
| or WEBrick on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or | |
| Oracle with eRuby- or Builder-based templates.", | |
| "version": "2.3.5", | |
| + "version_downloads": 2451, | |
| "authors": "David Heinemeier Hansson", | |
| "downloads": 134451, | |
| "project_uri": "http://gemcutter.org/gems/rails", | |
| diff --git a/test/unit/rubygem_test.rb b/test/unit/rubygem_test.rb | |
| index c45a66b..a93e80c 100644 | |
| --- a/test/unit/rubygem_test.rb | |
| +++ b/test/unit/rubygem_test.rb | |
| @@ -224,6 +224,7 @@ class RubygemTest < ActiveSupport::TestCase | |
| assert_equal @rubygem.slug, hash["slug"] | |
| assert_equal @rubygem.downloads, hash["downloads"] | |
| assert_equal @rubygem.versions.latest.number, hash["version"] | |
| + assert_equal @rubygem.versions.latest.downloads_count, hash["version_downloads"] | |
| assert_equal @rubygem.versions.latest.authors, hash["authors"] | |
| assert_equal @rubygem.versions.latest.info, hash["info"] | |
| assert_equal "http://#{HOST}/gems/#{@rubygem.name}", hash["project_uri"] | |
| -- | |
| 1.6.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment