lib/gems/client.rb in gems-0.0.5 vs lib/gems/client.rb in gems-0.0.6

- old
+ new

@@ -1,5 +1,6 @@ +require 'date' require 'gems/configuration' require 'gems/connection' require 'gems/request' module Gems @@ -49,15 +50,21 @@ # Returns the number of downloads by day for a particular gem version # # @param gem [String] The name of a gem. # @param version [String] The version of a gem. + # @param from [Date] Search start date. + # @param to [Date] Search end date. # @return [Hashie::Mash] # @example - # Gems.downloads 'coulda', '0.6.3' - def downloads(gem, version) - get("/api/v1/versions/#{gem}-#{version}/downloads", {}, :json) + # Gems.downloads 'coulda', '0.6.3', Date.today - 30, Date.today + def downloads(gem, version, from=nil, to=Date.today) + if from + get("/api/v1/versions/#{gem}-#{version}/downloads/search", {:from => from.to_s, :to => to.to_s}, :json) + else + get("/api/v1/versions/#{gem}-#{version}/downloads", {}, :json) + end end # Returns an array of hashes for all versions of given gems # # @param gems [Array] A list of gem names @@ -90,8 +97,33 @@ # end # Gems.gems def gems response = get("/api/v1/gems") format.to_s.downcase == 'xml' ? response['rubygems'] : response + end + + # View all owners of a gem that you own + # + # @param gem [String] The name of a gem. + # @return [Array] + # @example + # Gems.configure do |config| + # config.key = '701243f217cdf23b1370c7b66b65ca97' + # end + # Gems.owners('gemcutter') + def owners(gem) + get("/api/v1/gems/#{gem}/owners", {}, :json) + end + + # List the webhooks registered under your account + # + # @return [Hashie::Mash] + # @example + # Gems.configure do |config| + # config.key = '701243f217cdf23b1370c7b66b65ca97' + # end + # Gems.web_hooks + def web_hooks + get("/api/v1/web_hooks", {}, :json) end end end