lib/gems/client.rb in gems-0.1.0 vs lib/gems/client.rb in gems-0.2.0
- old
+ new
@@ -56,11 +56,11 @@
# @param to [Date] Search end date.
# @return [Hashie::Mash]
# @example
# Gems.downloads 'coulda', '0.6.3', Date.today - 30, Date.today
def downloads(gem_name, gem_version=nil, from=nil, to=Date.today)
- gem_version ||= info(gem_name).version
+ gem_version ||= info(gem_name)['version']
if from
get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads/search", {:from => from.to_s, :to => to.to_s}, :json)
else
get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads", {}, :json)
end
@@ -171,21 +171,31 @@
# Gems.fire_web_hook("rails", "http://example.com")
def fire_web_hook(gem_name, url)
post("/api/v1/web_hooks/fire", {:gem_name => gem_name, :url => url}, :raw)
end
+ # Submit a gem to RubyGems.org
+ #
+ # @param gem [File] A built gem.
+ # @return [String]
+ # @example
+ # Gems.push(File.new("pkg/gemcutter-0.2.1.gem"))
+ def push(gem)
+ post("/api/v1/gems", gem.read, :raw, 'application/octet-stream')
+ end
+
# Remove a gem from RubyGems.org's index
#
# @param gem_name [String] The name of a gem.
# @param gem_version [String] The version of a gem.
# @param options [Hash] A customizable set of options.
# @option options [String] :platform
# @return [String]
# @example
# Gems.yank("gemcutter", "0.2.1", {:platform => "x86-darwin-10"})
def yank(gem_name, gem_version=nil, options={})
- gem_version ||= info(gem_name).version
+ gem_version ||= info(gem_name)['version']
delete("/api/v1/gems/yank", options.merge(:gem_name => gem_name, :version => gem_version), :raw)
end
# Update a previously yanked gem back into RubyGems.org's index
#
@@ -195,10 +205,10 @@
# @option options [String] :platform
# @return [String]
# @example
# Gems.unyank("gemcutter", "0.2.1", {:platform => "x86-darwin-10"})
def unyank(gem_name, gem_version=nil, options={})
- gem_version ||= info(gem_name).version
+ gem_version ||= info(gem_name)['version']
put("/api/v1/gems/unyank", options.merge(:gem_name => gem_name, :version => gem_version), :raw)
end
end
end