Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created January 6, 2010 16:05
Show Gist options
  • Select an option

  • Save jhsu/270365 to your computer and use it in GitHub Desktop.

Select an option

Save jhsu/270365 to your computer and use it in GitHub Desktop.
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"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment