Class: Gems::Client
Instance Method Summary collapse
-
#add_owner(gem_name, owner) ⇒ String
Add an owner to a RubyGem you own, giving that user permission to manage it.
-
#add_web_hook(gem_name, url) ⇒ String
Create a webhook.
-
#api_key ⇒ String
Retrieve your API key using HTTP basic auth.
-
#dependencies(*gems) ⇒ Array
Returns an array of hashes for all versions of given gems.
-
#downloads(gem_name, gem_version = nil, from = nil, to = Date.today) ⇒ Hash
Returns the number of downloads by day for a particular gem version.
-
#fire_web_hook(gem_name, url) ⇒ String
Test fire a webhook.
-
#gems(user_handle = nil) ⇒ Array
List all gems that you own.
-
#info(gem_name) ⇒ Hash
Returns some basic information about the given gem.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#just_updated(options = {}) ⇒ Array
Returns the 50 most recently updated gems.
-
#latest(options = {}) ⇒ Array
Returns the 50 gems most recently added to RubyGems.org (for the first time).
-
#most_downloaded ⇒ Array
Returns an array containing the top 50 downloaded gem versions of all time.
-
#most_downloaded_today ⇒ Array
Returns an array containing the top 50 downloaded gem versions for today.
-
#owners(gem_name) ⇒ Array
View all owners of a gem that you own.
-
#push(gem) ⇒ String
Submit a gem to RubyGems.org.
-
#remove_owner(gem_name, owner) ⇒ String
Remove a user's permission to manage a RubyGem you own.
-
#remove_web_hook(gem_name, url) ⇒ String
Remove a webhook.
-
#reverse_dependencies(gem_name, options = {}) ⇒ Array
Returns an array of all the reverse dependencies to the given gem.
-
#search(query) ⇒ Array<Hash>
Returns an array of active gems that match the query.
-
#total_downloads(gem_name = nil, gem_version = nil) ⇒ Hash
Returns the total number of downloads for a particular gem.
-
#unyank(gem_name, gem_version = nil, options = {}) ⇒ String
Update a previously yanked gem back into RubyGems.org's index.
-
#versions(gem_name) ⇒ Hash
Returns an array of gem version details.
-
#web_hooks ⇒ Hash
List the webhooks registered under your account.
-
#yank(gem_name, gem_version = nil, options = {}) ⇒ String
Remove a gem from RubyGems.org's index.
Methods included from Request
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/gems/client.rb', line 11 def initialize(={}) = Gems..merge() Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
Instance Method Details
#add_owner(gem_name, owner) ⇒ String
Add an owner to a RubyGem you own, giving that user permission to manage it
191 192 193 |
# File 'lib/gems/client.rb', line 191 def add_owner(gem_name, owner) post("/api/v1/gems/#{gem_name}/owners", {:email => owner}) end |
#add_web_hook(gem_name, url) ⇒ String
Create a webhook
226 227 228 |
# File 'lib/gems/client.rb', line 226 def add_web_hook(gem_name, url) post("/api/v1/web_hooks", {:gem_name => gem_name, :url => url}) end |
#api_key ⇒ String
Retrieve your API key using HTTP basic auth
288 289 290 |
# File 'lib/gems/client.rb', line 288 def api_key get('/api/v1/api_key') end |
#dependencies(*gems) ⇒ Array
Returns an array of hashes for all versions of given gems
299 300 301 302 |
# File 'lib/gems/client.rb', line 299 def dependencies(*gems) response = get('/api/v1/dependencies', {:gems => gems.join(',')}) Marshal.load(response) end |
#downloads(gem_name, gem_version = nil, from = nil, to = Date.today) ⇒ Hash
Returns the number of downloads by day for a particular gem version
161 162 163 164 165 166 167 168 169 |
# File 'lib/gems/client.rb', line 161 def downloads(gem_name, gem_version=nil, from=nil, to=Date.today) gem_version ||= info(gem_name)['version'] response = if from get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads/search.yaml", {:from => from.to_s, :to => to.to_s}) else get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads.yaml") end YAML.load(response) end |
#fire_web_hook(gem_name, url) ⇒ String
Test fire a webhook
250 251 252 |
# File 'lib/gems/client.rb', line 250 def fire_web_hook(gem_name, url) post("/api/v1/web_hooks/fire", {:gem_name => gem_name, :url => url}) end |
#gems(user_handle = nil) ⇒ Array
List all gems that you own
49 50 51 52 53 54 55 56 |
# File 'lib/gems/client.rb', line 49 def gems(user_handle=nil) response = if user_handle get("/api/v1/owners/#{user_handle}/gems.yaml") else get("/api/v1/gems.yaml") end YAML.load(response) end |
#info(gem_name) ⇒ Hash
Returns some basic information about the given gem
25 26 27 28 |
# File 'lib/gems/client.rb', line 25 def info(gem_name) response = get("/api/v1/gems/#{gem_name}.yaml") YAML.load(response) end |
#just_updated(options = {}) ⇒ Array
Returns the 50 most recently updated gems
273 274 275 276 |
# File 'lib/gems/client.rb', line 273 def just_updated(={}) response = get("/api/v1/activity/just_updated.yaml", ) YAML.load(response) end |
#latest(options = {}) ⇒ Array
Returns the 50 gems most recently added to RubyGems.org (for the first time)
261 262 263 264 |
# File 'lib/gems/client.rb', line 261 def latest(={}) response = get("/api/v1/activity/latest.yaml", ) YAML.load(response) end |
#most_downloaded ⇒ Array
Returns an array containing the top 50 downloaded gem versions of all time
146 147 148 149 |
# File 'lib/gems/client.rb', line 146 def most_downloaded response = get("/api/v1/downloads/all.yaml") YAML.load(response)[:gems] end |
#most_downloaded_today ⇒ Array
Returns an array containing the top 50 downloaded gem versions for today
135 136 137 138 |
# File 'lib/gems/client.rb', line 135 def most_downloaded_today response = get("/api/v1/downloads/top.yaml") YAML.load(response)[:gems] end |
#owners(gem_name) ⇒ Array
View all owners of a gem that you own
178 179 180 181 |
# File 'lib/gems/client.rb', line 178 def owners(gem_name) response = get("/api/v1/gems/#{gem_name}/owners.yaml") YAML.load(response) end |
#push(gem) ⇒ String
Submit a gem to RubyGems.org
65 66 67 |
# File 'lib/gems/client.rb', line 65 def push(gem) post("/api/v1/gems", gem.read, 'application/octet-stream') end |
#remove_owner(gem_name, owner) ⇒ String
Remove a user's permission to manage a RubyGem you own
203 204 205 |
# File 'lib/gems/client.rb', line 203 def remove_owner(gem_name, owner) delete("/api/v1/gems/#{gem_name}/owners", {:email => owner}) end |
#remove_web_hook(gem_name, url) ⇒ String
Remove a webhook
238 239 240 |
# File 'lib/gems/client.rb', line 238 def remove_web_hook(gem_name, url) delete("/api/v1/web_hooks/remove", {:gem_name => gem_name, :url => url}) end |
#reverse_dependencies(gem_name, options = {}) ⇒ Array
Returns an array of all the reverse dependencies to the given gem.
312 313 314 315 |
# File 'lib/gems/client.rb', line 312 def reverse_dependencies(gem_name, ={}) response = get("/api/v1/gems/#{gem_name}/reverse_dependencies.yaml", ) YAML.load(response) end |
#search(query) ⇒ Array<Hash>
Returns an array of active gems that match the query
37 38 39 40 |
# File 'lib/gems/client.rb', line 37 def search(query) response = get("/api/v1/search.yaml", {:query => query}) YAML.load(response) end |
#total_downloads(gem_name = nil, gem_version = nil) ⇒ Hash
Returns the total number of downloads for a particular gem
119 120 121 122 123 124 125 126 127 |
# File 'lib/gems/client.rb', line 119 def total_downloads(gem_name=nil, gem_version=nil) response = if gem_name gem_version ||= info(gem_name)['version'] get("/api/v1/downloads/#{gem_name}-#{gem_version}.yaml") else get("/api/v1/downloads.yaml") end YAML.load(response) end |
#unyank(gem_name, gem_version = nil, options = {}) ⇒ String
Update a previously yanked gem back into RubyGems.org's index
94 95 96 97 |
# File 'lib/gems/client.rb', line 94 def unyank(gem_name, gem_version=nil, ={}) gem_version ||= info(gem_name)['version'] put("/api/v1/gems/unyank", .merge(:gem_name => gem_name, :version => gem_version)) end |
#versions(gem_name) ⇒ Hash
Returns an array of gem version details
106 107 108 109 |
# File 'lib/gems/client.rb', line 106 def versions(gem_name) response = get("/api/v1/versions/#{gem_name}.yaml") YAML.load(response) end |
#web_hooks ⇒ Hash
List the webhooks registered under your account
213 214 215 216 |
# File 'lib/gems/client.rb', line 213 def web_hooks response = get("/api/v1/web_hooks.yaml") YAML.load(response) end |
#yank(gem_name, gem_version = nil, options = {}) ⇒ String
Remove a gem from RubyGems.org's index
79 80 81 82 |
# File 'lib/gems/client.rb', line 79 def yank(gem_name, gem_version=nil, ={}) gem_version ||= info(gem_name)['version'] delete("/api/v1/gems/yank", .merge(:gem_name => gem_name, :version => gem_version)) end |