Skip to content

Commit ae2a9af

Browse files
authored
Merge pull request #109 from rubygems/remove-downloads-method
Remove `Gems.downloads` since the API endpoint has been deprecated
2 parents 94ae256 + 922bc7a commit ae2a9af

File tree

5 files changed

+0
-169
lines changed

5 files changed

+0
-169
lines changed

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ Gems.total_downloads 'rails_admin', '0.0.1'
6363
# Returns an array containing the top 50 downloaded gem versions of all time.
6464
Gems.most_downloaded
6565

66-
# Return the total number of downloads by day for rails_admin 0.0.1.
67-
# (Defaults to the latest version if no version is specified.)
68-
Gems.downloads 'rails_admin', '0.0.1'
69-
70-
# Return the number of downloads by day for coulda 0.6.3 for the past 90 days.
71-
# (Defaults to the latest version if no version is specified.)
72-
Gems.downloads 'coulda', '0.6.3', Date.today - 90, Date.today
73-
74-
# Return the number of downloads by day for coulda 0.6.3 for the past year.
75-
Gems.downloads 'coulda', '0.6.3', Date.today - 365, Date.today
76-
7766
# View all owners of a gem that you own.
7867
Gems.owners 'gemcutter'
7968

lib/gems/v1/client.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,6 @@ def most_downloaded
154154
JSON.parse(response)['gems']
155155
end
156156

157-
# Returns the number of downloads by day for a particular gem version
158-
#
159-
# @authenticated false
160-
# @param gem_name [String] The name of a gem.
161-
# @param gem_version [String] The version of a gem.
162-
# @param from [Date] Search start date.
163-
# @param to [Date] Search end date.
164-
# @return [Hash]
165-
# @example
166-
# Gems.downloads 'coulda', '0.6.3', Date.today - 30, Date.today
167-
def downloads(gem_name, gem_version = nil, from = nil, to = Date.today)
168-
gem_version ||= info(gem_name)['version']
169-
response = from ? get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads/search.json", :from => from.to_s, :to => to.to_s) : get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads.json")
170-
JSON.parse(response)
171-
end
172157

173158
# View all owners of a gem that you own
174159
#

spec/fixtures/downloads.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/fixtures/downloads.yaml

Lines changed: 0 additions & 91 deletions
This file was deleted.

spec/gems/client_v1_spec.rb

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -262,57 +262,6 @@
262262
end
263263
end
264264

265-
describe '#downloads' do
266-
context 'with no dates or version specified' do
267-
before do
268-
stub_get('/api/v1/gems/coulda.json').
269-
to_return(:body => fixture('rails.json'))
270-
stub_get('/api/v1/versions/coulda-3.0.9/downloads.json').
271-
to_return(:body => fixture('downloads.json'))
272-
end
273-
it 'returns the number of downloads by day for a particular gem version' do
274-
downloads = Gems.downloads 'coulda'
275-
expect(a_get('/api/v1/gems/coulda.json')).to have_been_made
276-
expect(a_get('/api/v1/versions/coulda-3.0.9/downloads.json')).to have_been_made
277-
expect(downloads['2011-06-22']).to eq 8
278-
end
279-
end
280-
context 'with no dates specified' do
281-
before do
282-
stub_get('/api/v1/versions/coulda-0.6.3/downloads.json').
283-
to_return(:body => fixture('downloads.json'))
284-
end
285-
it 'returns the number of downloads by day for a particular gem version' do
286-
downloads = Gems.downloads 'coulda', '0.6.3'
287-
expect(a_get('/api/v1/versions/coulda-0.6.3/downloads.json')).to have_been_made
288-
expect(downloads['2011-06-22']).to eq 8
289-
end
290-
end
291-
context 'with from date specified' do
292-
before do
293-
stub_get('/api/v1/versions/coulda-0.6.3/downloads/search.json').
294-
with(:query => {'from' => '2011-01-01', 'to' => Date.today.to_s}).
295-
to_return(:body => fixture('downloads.json'))
296-
end
297-
it 'returns the number of downloads by day for a particular gem version' do
298-
downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01')
299-
expect(a_get('/api/v1/versions/coulda-0.6.3/downloads/search.json').with(:query => {'from' => '2011-01-01', 'to' => Date.today.to_s})).to have_been_made
300-
expect(downloads['2011-06-22']).to eq 8
301-
end
302-
end
303-
context 'with from and to dates specified' do
304-
before do
305-
stub_get('/api/v1/versions/coulda-0.6.3/downloads/search.json').
306-
with(:query => {'from' => '2011-01-01', 'to' => '2011-06-28'}).
307-
to_return(:body => fixture('downloads.json'))
308-
end
309-
it 'returns the number of downloads by day for a particular gem version' do
310-
downloads = Gems.downloads 'coulda', '0.6.3', Date.parse('2011-01-01'), Date.parse('2011-06-28')
311-
expect(a_get('/api/v1/versions/coulda-0.6.3/downloads/search.json').with(:query => {'from' => '2011-01-01', 'to' => '2011-06-28'})).to have_been_made
312-
expect(downloads['2011-06-22']).to eq 8
313-
end
314-
end
315-
end
316265

317266
describe '#owners' do
318267
before do

0 commit comments

Comments
 (0)