bestgems 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 437a5e1801d2120bd414cbff9caf29e5bd4cb378
4
+ data.tar.gz: a5777bdf038f5e5f176f0f7b546dfa1824493cfc
5
+ SHA512:
6
+ metadata.gz: f5a1f44bd8389806964e62604b475a607ae958bee4304cc066b1e42a40cf48d81e865177806deab34fa26eb0dded226ed2c301e99072388381698a8c58be103c
7
+ data.tar.gz: 7ad21af4b139dd40fa562b5bd738fe87fba7b6f681dccdb9622fa494b3471ed502c9f4f01b0ae4bb0e00e23e88dab2843ad8e8604827e2aba79be72f6282a8c0
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'pry'
5
+ end
6
+
7
+ group :test do
8
+ gem 'vcr', '~>2.9.2'
9
+ gem 'webmock', '~>1.18.0'
10
+ end
11
+
12
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 kyoendo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Bestgems
2
+
3
+ Ruby wrapper for the BestGems.org API.
4
+
5
+ >[BestGems -- Ruby Gems Download Ranking](http://bestgems.org/ "BestGems -- Ruby Gems Download Ranking")
6
+ >
7
+ >[BestGems API v1 Specification · xmisao/bestgems.org Wiki](https://github.com/xmisao/bestgems.org/wiki/BestGems-API-v1-Specification "BestGems API v1 Specification · xmisao/bestgems.org Wiki")
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'bestgems'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bestgems
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'bestgems'
27
+
28
+ client = Bestgems.client
29
+
30
+ client.total_downloads(:rack) # => [{:date=>"2014-08-06", :total_downloads=>48365953}, {:date=>"2014-08-05", :total_downloads=>48305390}, {:date=>"2014-08-04", :total_downloads=>48246069}, {:date=>"2014-08-03", :total_downloads=>48203248}, {:date=>"2014-08-02", :total_downloads=>48172608}, ... ]
31
+
32
+ client.daily_downloads(:rack) # => [{:date=>"2014-08-06", :daily_downloads=>60563}, {:date=>"2014-08-05", :daily_downloads=>59321}, {:date=>"2014-08-04", :daily_downloads=>42821}, {:date=>"2014-08-03", :daily_downloads=>30640}, ... ]
33
+
34
+ client.total_ranking(:rack) # => [{:date=>"2014-08-06", :total_ranking=>2}, {:date=>"2014-08-05", :total_ranking=>2}, {:date=>"2014-08-04", :total_ranking=>2}, {:date=>"2014-08-03", :total_ranking=>2}, {:date=>"2014-08-02", :total_ranking=>2}, ... ]
35
+
36
+ client.daily_ranking(:rack) # => [{:date=>"2014-08-06", :daily_ranking=>6}, {:date=>"2014-08-05", :daily_ranking=>7}, {:date=>"2014-08-04", :daily_ranking=>4}, {:date=>"2014-08-03", :daily_ranking=>3}, {:date=>"2014-08-02", :daily_ranking=>3}, ... ]
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/[my-github-username]/bestgems/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bestgems.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bestgems/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bestgems"
8
+ spec.version = Bestgems::VERSION
9
+ spec.authors = ["kyoendo"]
10
+ spec.email = ["postagie@gmail.com"]
11
+ spec.summary = %q{Ruby wrapper for the BestGems.org API}
12
+ spec.homepage = "https://github.com/melborne/bestgems"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "faraday"
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/lib/bestgems.rb ADDED
@@ -0,0 +1,25 @@
1
+ require "bestgems/version"
2
+ require "bestgems/client"
3
+
4
+ module Bestgems
5
+ API_HOST = "http://bestgems.org/api".freeze
6
+ API_VERSION = "v1".freeze
7
+
8
+ class << self
9
+ def api_host
10
+ ENV['BESTGEMS_API_HOST'] || API_HOST
11
+ end
12
+
13
+ def api_version
14
+ ENV['BESTGEMS_API_VERSION'] || API_VERSION
15
+ end
16
+
17
+ def api_gems_endpoint
18
+ File.join(api_host, api_version, 'gems')
19
+ end
20
+
21
+ def client
22
+ @client ||= Client.new
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ require "faraday"
2
+ require "bestgems/client/trends"
3
+
4
+ module Bestgems
5
+ class Client
6
+ include Bestgems::Client::Trends
7
+
8
+ class NotFound < StandardError; end
9
+
10
+ def get(url, **opts)
11
+ request :get, url, opts
12
+ end
13
+
14
+ def request(method, path, **opts)
15
+ response = agent.send(method, path.to_s, opts)
16
+ case response.status
17
+ when 404
18
+ raise NotFound
19
+ when 200
20
+ response.body
21
+ end
22
+ end
23
+
24
+ def agent
25
+ @agent ||= ::Faraday.new do |http|
26
+ http.request :url_encoded
27
+ # http.response :logger
28
+ http.adapter :net_http
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require "json"
2
+
3
+ module Bestgems
4
+ class Client
5
+ module Trends
6
+ def total_downloads(gem_name)
7
+ res = get "#{Bestgems.api_gems_endpoint}/#{gem_name}/total_downloads.json"
8
+ json2rb_obj(res)
9
+ end
10
+
11
+ def daily_downloads(gem_name)
12
+ res = get "#{Bestgems.api_gems_endpoint}/#{gem_name}/daily_downloads.json"
13
+ json2rb_obj(res)
14
+ end
15
+
16
+ def total_ranking(gem_name)
17
+ res = get "#{Bestgems.api_gems_endpoint}/#{gem_name}/total_ranking.json"
18
+ json2rb_obj(res)
19
+ end
20
+
21
+ def daily_ranking(gem_name)
22
+ res = get "#{Bestgems.api_gems_endpoint}/#{gem_name}/daily_ranking.json"
23
+ json2rb_obj(res)
24
+ end
25
+
26
+ def json2rb_obj(data)
27
+ JSON.parse(data).map do |h|
28
+ h.inject({}) { |h, (k, v)| h[k.intern] = v; h }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module Bestgems
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bestgems::Client do
4
+ describe ".get", vcr:{cassette_name:'get'} do
5
+ let(:client) { Bestgems::Client.new }
6
+ before do
7
+ @test_endpoint = "http://bestgems.org"
8
+ end
9
+
10
+ it "handles request" do
11
+ client.get @test_endpoint
12
+ assert_requested :get, @test_endpoint
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bestgems::Client do
4
+ let(:client) { Bestgems::Client.new }
5
+
6
+ describe "#total_downloads", vcr:{cassette_name:'total_downloads'} do
7
+ it "gets an array of data hashes" do
8
+ res = client.total_downloads('colcolor')
9
+ expect(res).to be_a Array
10
+ expect(res.first).to be_a Hash
11
+ expect(res.first.keys).to contain_exactly(:date, :total_downloads)
12
+ end
13
+
14
+ context "with an absent gem name", vcr:{cassette_name:'total_downloads_error'} do
15
+ it "raises NotFound error" do
16
+ expect {client.total_downloads ''}.to raise_error(Bestgems::Client::NotFound)
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "#daily_downloads", vcr:{cassette_name:'daily_downloads'} do
22
+ it "gets an array of data hashes" do
23
+ res = client.daily_downloads('colcolor')
24
+ expect(res).to be_a Array
25
+ expect(res.first).to be_a Hash
26
+ expect(res.first.keys).to contain_exactly(:date, :daily_downloads)
27
+ end
28
+ end
29
+
30
+ describe "#total_ranking", vcr:{cassette_name:'total_ranking'} do
31
+ it "gets an array of data hashes" do
32
+ res = client.total_ranking('colcolor')
33
+ expect(res).to be_a Array
34
+ expect(res.first).to be_a Hash
35
+ expect(res.first.keys).to contain_exactly(:date, :total_ranking)
36
+ end
37
+ end
38
+
39
+ describe "#daily_ranking", vcr:{cassette_name:'daily_ranking'} do
40
+ it "gets an array of data hashes" do
41
+ res = client.daily_ranking('colcolor')
42
+ expect(res).to be_a Array
43
+ expect(res.first).to be_a Hash
44
+ expect(res.first.keys).to contain_exactly(:date, :daily_ranking)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bestgems do
4
+ it 'has a version number' do
5
+ expect(Bestgems::VERSION).not_to be nil
6
+ end
7
+
8
+ describe ".client" do
9
+ it "creates an Bestgems Client" do
10
+ expect(Bestgems.client).to be_kind_of Bestgems::Client
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/api/v1/gems/colcolor/daily_downloads.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:44:49 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '982'
29
+ Connection:
30
+ - keep-alive
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"date":"2014-08-06","daily_downloads":10},{"date":"2014-08-05","daily_downloads":15},{"date":"2014-08-04","daily_downloads":9},{"date":"2014-08-03","daily_downloads":13},{"date":"2014-08-02","daily_downloads":19},{"date":"2014-08-01","daily_downloads":8},{"date":"2014-07-31","daily_downloads":59},{"date":"2014-07-30","daily_downloads":57},{"date":"2014-07-29","daily_downloads":19},{"date":"2014-07-28","daily_downloads":25},{"date":"2014-07-27","daily_downloads":4},{"date":"2014-07-26","daily_downloads":1},{"date":"2014-07-25","daily_downloads":9},{"date":"2014-07-24","daily_downloads":69},{"date":"2014-07-23","daily_downloads":20},{"date":"2014-07-22","daily_downloads":1},{"date":"2014-07-21","daily_downloads":19},{"date":"2014-07-20","daily_downloads":14},{"date":"2014-07-19","daily_downloads":7},{"date":"2014-07-18","daily_downloads":0},{"date":"2014-07-17","daily_downloads":3},{"date":"2014-07-16","daily_downloads":38},{"date":"2014-07-15","daily_downloads":159}]'
36
+ http_version:
37
+ recorded_at: Thu, 07 Aug 2014 01:44:24 GMT
38
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/api/v1/gems/colcolor/daily_ranking.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:44:49 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '996'
29
+ Connection:
30
+ - keep-alive
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"date":"2014-08-06","daily_ranking":8533},{"date":"2014-08-05","daily_ranking":5292},{"date":"2014-08-04","daily_ranking":5541},{"date":"2014-08-03","daily_ranking":3311},{"date":"2014-08-02","daily_ranking":8345},{"date":"2014-08-01","daily_ranking":6557},{"date":"2014-07-31","daily_ranking":3900},{"date":"2014-07-30","daily_ranking":8676},{"date":"2014-07-29","daily_ranking":13927},{"date":"2014-07-28","daily_ranking":5333},{"date":"2014-07-27","daily_ranking":5050},{"date":"2014-07-26","daily_ranking":11628},{"date":"2014-07-25","daily_ranking":24633},{"date":"2014-07-24","daily_ranking":4591},{"date":"2014-07-23","daily_ranking":4898},{"date":"2014-07-22","daily_ranking":30629},{"date":"2014-07-21","daily_ranking":5702},{"date":"2014-07-20","daily_ranking":6884},{"date":"2014-07-19","daily_ranking":11234},{"date":"2014-07-18","daily_ranking":27172},{"date":"2014-07-17","daily_ranking":9930},{"date":"2014-07-16","daily_ranking":3749},{"date":"2014-07-15","daily_ranking":1694}]'
36
+ http_version:
37
+ recorded_at: Thu, 07 Aug 2014 01:44:24 GMT
38
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,126 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:26:33 GMT
25
+ Content-Type:
26
+ - text/html;charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ body:
38
+ encoding: UTF-8
39
+ string: "<!DOCTYPE html>\n<html>\n<head>\n<title>BestGems -- Ruby Gems Download
40
+ Ranking</title>\n<link href=\"../bootstrap/css/bootstrap.css\" rel=\"stylesheet\">\n<link
41
+ href=\"../css/theme.css\" rel=\"stylesheet\">\n</head>\n<body>\n\n<div class=\"container-narrow\">\n\t<div
42
+ class=\"masthead\">\n\t<ul class=\"nav nav-pills pull-right\">\n\t\t<li><a
43
+ href=\"/total\">Total</a></li>\n\t\t<li><a href=\"/daily\">Daily</a></li>\n\t\t<li><a
44
+ href=\"/featured\">Featured</a></li>\n\t\t<li><a href=\"https://github.com/xmisao/bestgems.org/wiki/BestGems-API-v1-Specification\">API</a></li>\n\t\t<li><a
45
+ href=\"/about\">About</a></li>\n\t\t<li>\n\t\t\t<form class=\"form-search\"
46
+ action=\"/search\" method=\"GET\">\n\t\t\t\t<input type=\"text\" class=\"input-medium
47
+ search-query\" name=\"q\">\n\t\t\t\t<button type=\"submit\" class=\"btn\"><i
48
+ class=\"icon-search\"></i></button>\n\t\t\t</form>\n\t\t</li>\n\t</ul>\n\t<h3><a
49
+ href=\"/\" class=\"header\">BestGems</a></h3>\n</div>\n\n\n\t<hr>\n\n\t<div
50
+ class=\"jumbotron\">\n\t\t<h1 class=\"logo\">BestGems</h1>\n\t\t<p class=\"lead\">Ruby
51
+ gems download ranking. Find the best gem package for you!</p>\n <p>BestGems.org
52
+ is <a href=\"https://github.com/xmisao/bestgems.org\">opensouce</a>. Please,
53
+ contribute!</p>\n\t</div>\n\n\t<hr>\n\n\t<div class=\"row-fluid marketing\">\n\t\t<div
54
+ class=\"span6\">\n\t\t\t<h4><a href=\"/total\">Total Downloads Ranking</a></h4>\n\t\t\t<table
55
+ class=\"table table-striped\">\n\t\t\t\t<tr><th>Rank</th><th>Downloads</th><th>Name</th></tr>\n\t\t\t\t<tr><td
56
+ class=\"center\">1</td><td class=\"center\">53,409,869</td><td><a href=\"/gems/rake\">rake</a></td></tr>\n\t\t\t\t<tr><td
57
+ class=\"center\">2</td><td class=\"center\">48,365,953</td><td><a href=\"/gems/rack\">rack</a></td></tr>\n\t\t\t\t<tr><td
58
+ class=\"center\">3</td><td class=\"center\">46,457,023</td><td><a href=\"/gems/thor\">thor</a></td></tr>\n\t\t\t\t<tr><td
59
+ class=\"center\">4</td><td class=\"center\">44,745,927</td><td><a href=\"/gems/activesupport\">activesupport</a></td></tr>\n\t\t\t\t<tr><td
60
+ class=\"center\">5</td><td class=\"center\">42,146,688</td><td><a href=\"/gems/multi_json\">multi_json</a></td></tr>\n\t\t\t\t<tr><td
61
+ class=\"center\">6</td><td class=\"center\">41,887,767</td><td><a href=\"/gems/json\">json</a></td></tr>\n\t\t\t\t<tr><td
62
+ class=\"center\">7</td><td class=\"center\">40,740,166</td><td><a href=\"/gems/mime-types\">mime-types</a></td></tr>\n\t\t\t\t<tr><td
63
+ class=\"center\">8</td><td class=\"center\">38,925,105</td><td><a href=\"/gems/i18n\">i18n</a></td></tr>\n\t\t\t\t<tr><td
64
+ class=\"center\">9</td><td class=\"center\">37,887,715</td><td><a href=\"/gems/rails\">rails</a></td></tr>\n\t\t\t\t<tr><td
65
+ class=\"center\">10</td><td class=\"center\">37,694,788</td><td><a href=\"/gems/builder\">builder</a></td></tr>\n\t\t\t</table>\n\t\t\t<p
66
+ class=\"text-right\"><a class=\"btn\" href=\"/total\">more...</a></p>\n\t\t</div>\n\t\t<div
67
+ class=\"span6\">\n\t\t\t<h4><a href=\"/daily\">Daily Downloads Ranking</a></h4>\n\t\t\t<table
68
+ class=\"table table-striped\">\n\t\t\t\t<tr><th>Rank</th><th>Downloads</th><th>Name</th></tr>\n\t\t\t\t<tr><td
69
+ class=\"center\">1</td><td class=\"center\">73,159</td><td><a href=\"/gems/rake\">rake</a></td></tr>\n\t\t\t\t<tr><td
70
+ class=\"center\">2</td><td class=\"center\">69,708</td><td><a href=\"/gems/multi_json\">multi_json</a></td></tr>\n\t\t\t\t<tr><td
71
+ class=\"center\">3</td><td class=\"center\">66,200</td><td><a href=\"/gems/json\">json</a></td></tr>\n\t\t\t\t<tr><td
72
+ class=\"center\">4</td><td class=\"center\">63,847</td><td><a href=\"/gems/mime-types\">mime-types</a></td></tr>\n\t\t\t\t<tr><td
73
+ class=\"center\">5</td><td class=\"center\">62,719</td><td><a href=\"/gems/i18n\">i18n</a></td></tr>\n\t\t\t\t<tr><td
74
+ class=\"center\">6</td><td class=\"center\">60,563</td><td><a href=\"/gems/rack\">rack</a></td></tr>\n\t\t\t\t<tr><td
75
+ class=\"center\">7</td><td class=\"center\">59,854</td><td><a href=\"/gems/activesupport\">activesupport</a></td></tr>\n\t\t\t\t<tr><td
76
+ class=\"center\">8</td><td class=\"center\">55,803</td><td><a href=\"/gems/builder\">builder</a></td></tr>\n\t\t\t\t<tr><td
77
+ class=\"center\">9</td><td class=\"center\">55,314</td><td><a href=\"/gems/thor\">thor</a></td></tr>\n\t\t\t\t<tr><td
78
+ class=\"center\">10</td><td class=\"center\">54,453</td><td><a href=\"/gems/tzinfo\">tzinfo</a></td></tr>\n\t\t\t</table>\n\t\t\t<p
79
+ class=\"text-right\"><a class=\"btn\" href=\"/daily\">more...</a></p>\n\t\t</div>\n\t</div>\n\t<div
80
+ class=\"row-fluid marketing\">\n\t\t<div class=\"span6\">\n\t\t\t<h4><a href=\"/featured\">Featured
81
+ Gems Ranking</a></h4>\n\t\t\t<table class=\"table table-striped\">\n\t\t\t\t<tr><th>Rank</th><th>Diff</th><th>Daily
82
+ Rank</th><th>Total Rank</th><th>Name</th></tr>\n\t\t\t\t<tr><td class=\"center\">1</td><td
83
+ class=\"center\">+56,515</td><td class=\"center\">659</td><td class=\"center\">57,174</td><td><a
84
+ href=\"/gems/rejectu\">rejectu</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">2</td><td
85
+ class=\"center\">+29,216</td><td class=\"center\">946</td><td class=\"center\">30,162</td><td><a
86
+ href=\"/gems/roadie-rails\">roadie-rails</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">3</td><td
87
+ class=\"center\">+25,822</td><td class=\"center\">977</td><td class=\"center\">26,799</td><td><a
88
+ href=\"/gems/mondupe\">mondupe</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">4</td><td
89
+ class=\"center\">+17,332</td><td class=\"center\">503</td><td class=\"center\">17,835</td><td><a
90
+ href=\"/gems/power_assert\">power_assert</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">5</td><td
91
+ class=\"center\">+12,469</td><td class=\"center\">967</td><td class=\"center\">13,436</td><td><a
92
+ href=\"/gems/mkfifo\">mkfifo</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">6</td><td
93
+ class=\"center\">+8,164</td><td class=\"center\">949</td><td class=\"center\">9,113</td><td><a
94
+ href=\"/gems/xml-fu\">xml-fu</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">7</td><td
95
+ class=\"center\">+7,152</td><td class=\"center\">879</td><td class=\"center\">8,031</td><td><a
96
+ href=\"/gems/toastr-rails\">toastr-rails</a></td></tr>\n\t\t\t\t<tr><td class=\"center\">8</td><td
97
+ class=\"center\">+6,472</td><td class=\"center\">894</td><td class=\"center\">7,366</td><td><a
98
+ href=\"/gems/zillabyte-cli\">zillabyte-cli</a></td></tr>\n\t\t\t\t<tr><td
99
+ class=\"center\">9</td><td class=\"center\">+6,220</td><td class=\"center\">898</td><td
100
+ class=\"center\">7,118</td><td><a href=\"/gems/zillabyte\">zillabyte</a></td></tr>\n\t\t\t\t<tr><td
101
+ class=\"center\">10</td><td class=\"center\">+5,686</td><td class=\"center\">980</td><td
102
+ class=\"center\">6,666</td><td><a href=\"/gems/crass\">crass</a></td></tr>\n\t\t\t</table>\n\t\t\t<p
103
+ class=\"text-right\"><a class=\"btn\" href=\"/featured\">more...</a></p>\n\t\t</div>\n\t\t<div
104
+ class=\"span6\">\n\t\t\t<h4>Statistics</h4>\n\t\t\t<table class=\"table table-striped\">\n\t\t\t\t<tr><th>#</th><th>Title</th></tr>\n\t\t\t\t<tr><td
105
+ class=\"center\">1</td><td><a href=\"/stat/gems\">Number of All Gems</a></td></tr>\n\t\t\t\t<tr><td
106
+ class=\"center\">2</td><td><a href=\"/stat/download\">Download Trends of All
107
+ Gems</a></td></tr>\n\t\t\t</table>\n\t\t\t<h4>Reports</h4>\n\t\t\t<table class=\"table
108
+ table-striped\">\n\t\t\t\t<tr><th>Title</th><th>Summary</th></tr>\n\t\t\t\t<tr><td><a
109
+ href=\"/reports/2013H2\">H2, 2013</td><td>Second half of 2013, semiannual
110
+ report. Between Jul 1 and Dec 31.</td></tr>\n\t\t\t\t<tr><td><a href=\"/reports/2013Q4\">Q4,
111
+ 2013</td><td>Final quarter of 2013, quarterly report. Between Oct 1 and Dec
112
+ 31.</td></tr>\n\t\t\t\t<tr><td><a href=\"/reports/2013Q3\">Q3, 2013</td><td>3rd
113
+ quarter of 2013, quarterly report. Between Jul 1 and Sep 30.</td></tr>\n\t\t\t</table>\n\t\t</div>\n\t</div>\n\n\t<div
114
+ class=\"row\">\n\t<script type=\"text/javascript\"><!--\n\tgoogle_ad_client
115
+ = \"ca-pub-8257359908391644\";\n\t/* bestgems_bottom */\n\tgoogle_ad_slot
116
+ = \"4115061810\";\n\tgoogle_ad_width = 728;\n\tgoogle_ad_height = 90;\n\t//-->\n\t</script>\n\t<script
117
+ type=\"text/javascript\"\n\tsrc=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n\t</script>\n</div>\n\n</div>\n\n\n<script
118
+ type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount',
119
+ 'UA-42168722-1']);\n _gaq.push(['_trackPageview']);\n\n (function() {\n
120
+ \ var ga = document.createElement('script'); ga.type = 'text/javascript';
121
+ ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl'
122
+ : 'http://www') + '.google-analytics.com/ga.js';\n var s = document.getElementsByTagName('script')[0];
123
+ s.parentNode.insertBefore(ga, s);\n })();\n\n</script>\n</body>\n</html>\n"
124
+ http_version:
125
+ recorded_at: Thu, 07 Aug 2014 01:26:08 GMT
126
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/api/v1/gems/colcolor/total_downloads.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:35:27 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '1056'
29
+ Connection:
30
+ - keep-alive
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"date":"2014-08-06","total_downloads":592},{"date":"2014-08-05","total_downloads":582},{"date":"2014-08-04","total_downloads":567},{"date":"2014-08-03","total_downloads":558},{"date":"2014-08-02","total_downloads":545},{"date":"2014-08-01","total_downloads":526},{"date":"2014-07-31","total_downloads":518},{"date":"2014-07-30","total_downloads":459},{"date":"2014-07-29","total_downloads":402},{"date":"2014-07-28","total_downloads":383},{"date":"2014-07-27","total_downloads":358},{"date":"2014-07-26","total_downloads":354},{"date":"2014-07-25","total_downloads":353},{"date":"2014-07-24","total_downloads":344},{"date":"2014-07-23","total_downloads":275},{"date":"2014-07-22","total_downloads":255},{"date":"2014-07-21","total_downloads":254},{"date":"2014-07-20","total_downloads":235},{"date":"2014-07-19","total_downloads":221},{"date":"2014-07-18","total_downloads":214},{"date":"2014-07-17","total_downloads":214},{"date":"2014-07-16","total_downloads":211},{"date":"2014-07-15","total_downloads":173},{"date":"2014-07-14","total_downloads":14}]'
36
+ http_version:
37
+ recorded_at: Thu, 07 Aug 2014 01:35:02 GMT
38
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/api/v1/gems//total_downloads.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 404
19
+ message: Not Found
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:50:32 GMT
25
+ Content-Type:
26
+ - text/html;charset=utf-8
27
+ Content-Length:
28
+ - '18'
29
+ Connection:
30
+ - keep-alive
31
+ X-Cascade:
32
+ - pass
33
+ X-Xss-Protection:
34
+ - 1; mode=block
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ body:
40
+ encoding: UTF-8
41
+ string: "<h1>Not Found</h1>"
42
+ http_version:
43
+ recorded_at: Thu, 07 Aug 2014 01:50:06 GMT
44
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://bestgems.org/api/v1/gems/colcolor/total_ranking.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx/1.2.1
23
+ Date:
24
+ - Thu, 07 Aug 2014 01:44:49 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '1057'
29
+ Connection:
30
+ - keep-alive
31
+ X-Content-Type-Options:
32
+ - nosniff
33
+ body:
34
+ encoding: UTF-8
35
+ string: '[{"date":"2014-08-06","total_ranking":68455},{"date":"2014-08-05","total_ranking":68680},{"date":"2014-08-04","total_ranking":69046},{"date":"2014-08-03","total_ranking":69224},{"date":"2014-08-02","total_ranking":69541},{"date":"2014-08-01","total_ranking":69947},{"date":"2014-07-31","total_ranking":70141},{"date":"2014-07-30","total_ranking":71403},{"date":"2014-07-29","total_ranking":72594},{"date":"2014-07-28","total_ranking":72913},{"date":"2014-07-27","total_ranking":73372},{"date":"2014-07-26","total_ranking":73442},{"date":"2014-07-25","total_ranking":73451},{"date":"2014-07-24","total_ranking":73564},{"date":"2014-07-23","total_ranking":75108},{"date":"2014-07-22","total_ranking":75538},{"date":"2014-07-21","total_ranking":75521},{"date":"2014-07-20","total_ranking":75921},{"date":"2014-07-19","total_ranking":76196},{"date":"2014-07-18","total_ranking":76330},{"date":"2014-07-17","total_ranking":76306},{"date":"2014-07-16","total_ranking":76358},{"date":"2014-07-15","total_ranking":77198},{"date":"2014-07-14","total_ranking":78402}]'
36
+ http_version:
37
+ recorded_at: Thu, 07 Aug 2014 01:44:24 GMT
38
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'bestgems'
3
+ require "vcr"
4
+ require "webmock/rspec"
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/cassettes'
8
+ c.hook_into :webmock
9
+ c.allow_http_connections_when_no_cassette = true
10
+ c.configure_rspec_metadata!
11
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bestgems
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kyoendo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - postagie@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bestgems.gemspec
84
+ - lib/bestgems.rb
85
+ - lib/bestgems/client.rb
86
+ - lib/bestgems/client/trends.rb
87
+ - lib/bestgems/version.rb
88
+ - spec/bestgems/client_spec.rb
89
+ - spec/bestgems/trends_spec.rb
90
+ - spec/bestgems_spec.rb
91
+ - spec/cassettes/daily_downloads.yml
92
+ - spec/cassettes/daily_ranking.yml
93
+ - spec/cassettes/get.yml
94
+ - spec/cassettes/total_downloads.yml
95
+ - spec/cassettes/total_downloads_error.yml
96
+ - spec/cassettes/total_ranking.yml
97
+ - spec/spec_helper.rb
98
+ homepage: https://github.com/melborne/bestgems
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.3.0
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Ruby wrapper for the BestGems.org API
122
+ test_files:
123
+ - spec/bestgems/client_spec.rb
124
+ - spec/bestgems/trends_spec.rb
125
+ - spec/bestgems_spec.rb
126
+ - spec/cassettes/daily_downloads.yml
127
+ - spec/cassettes/daily_ranking.yml
128
+ - spec/cassettes/get.yml
129
+ - spec/cassettes/total_downloads.yml
130
+ - spec/cassettes/total_downloads_error.yml
131
+ - spec/cassettes/total_ranking.yml
132
+ - spec/spec_helper.rb