gems 0.6.0 → 0.7.0

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.
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  *.rbc
2
- .DS_Store
3
2
  .bundle
4
3
  .config
5
4
  .yardoc
data/.travis.yml CHANGED
@@ -1,8 +1,10 @@
1
- before_install: "gem update --system 1.3.7"
1
+ language: ruby
2
2
  rvm:
3
+ - rbx-18mode
4
+ - rbx-19mode
5
+ - jruby-18mode
6
+ - jruby-19mode
3
7
  - 1.8.7
4
8
  - 1.9.2
5
9
  - 1.9.3
6
- - jruby
7
- - rbx
8
- - ree
10
+ - ruby-head
data/README.md CHANGED
@@ -4,59 +4,68 @@ Ruby wrapper for the RubyGems.org API.
4
4
  [travis]: http://travis-ci.org/rubygems/gems
5
5
  [gemnasium]: https://gemnasium.com/rubygems/gems
6
6
 
7
- ## <a name="installation"></a>Installation
7
+ ## Installation
8
8
  gem install gems
9
9
 
10
- ## <a name="documentation"></a>Documentation
10
+ ## Documentation
11
11
  [http://rdoc.info/gems/gems](http://rdoc.info/gems/gems)
12
12
 
13
- # <a name="examples"></a>Usage Examples
13
+ # Usage Examples
14
14
  require 'rubygems'
15
15
  require 'gems'
16
16
 
17
- # Returns some basic information about rails.
18
- puts Gems.info 'rails'
17
+ # Return some basic information about rails.
18
+ Gems.info 'rails'
19
19
 
20
- # Returns an array of active gems that match the query.
21
- puts Gems.search 'cucumber'
20
+ # Return an array of active gems that match the query.
21
+ Gems.search 'cucumber'
22
22
 
23
- # Returns an array of version details for coulda.
24
- puts Gems.versions 'coulda'
23
+ # Return all gems that you own.
24
+ Gems.gems
25
25
 
26
- # Returns the total number of downloads for rails_admin 0.0.0.
26
+ # Return all gems owned by Erik Michaels-Ober.
27
+ Gems.gems("sferik")
28
+
29
+ # Submit a gem to RubyGems.org.
30
+ Gems.push File.new 'gemcutter-0.2.1.gem'
31
+
32
+ # Remove a gem from RubyGems.org's index.
27
33
  # Defaults to the latest version if no version is specified.
28
- # Defaults to RubyGems.org if no gem name is specified.
29
- puts Gems.downloads 'rails_admin', '0.0.0'
34
+ Gems.yank 'bills', '0.0.1'
30
35
 
31
- # Returns the number of downloads by day for coulda 0.6.3 for the past 90 days.
36
+ # Update a previously yanked gem back into RubyGems.org's index.
32
37
  # Defaults to the latest version if no version is specified.
33
- puts Gems.downloads 'coulda', '0.6.3'
38
+ Gems.unyank 'bills', '0.0.1'
34
39
 
35
- # Returns the number of downloads by day for coulda 0.6.3 for the past year.
36
- puts Gems.downloads 'coulda', '0.6.3', Date.today - 365, Date.today
40
+ # Return an array of version details for coulda.
41
+ Gems.versions 'coulda'
37
42
 
38
- # Returns an array of gem dependency details for all versions of all the given gems.
39
- puts Gems.dependencies ['rails', 'thor']
43
+ # Return an array of version details for coulda.
44
+ Gems.versions 'coulda'
40
45
 
41
- # Retrieve your API key using HTTP basic authentication.
42
- Gems.configure do |config|
43
- config.username = 'nick@gemcutter.org'
44
- config.password = 'schwwwwing'
45
- end
46
- puts Gems.api_key
46
+ # Return the total number of downloads for rails_admin 0.0.1.
47
+ # (Defaults to the latest version if no version is specified.)
48
+ Gems.total_downloads 'rails_admin', '0.0.1'
47
49
 
48
- # The following methods require authentication.
49
- # By default, we load your API key from ~/.gem/credentails
50
- # You can override this default by specifying a custom API key.
51
- Gems.configure do |config|
52
- config.key '701243f217cdf23b1370c7b66b65ca97'
53
- end
50
+ # Returns an array containing the top 50 downloaded gem versions for today.
51
+ Gems.most_downloaded_today
52
+
53
+ # Returns an array containing the top 50 downloaded gem versions of all time.
54
+ Gems.most_downloaded
55
+
56
+ # Return the total number of downloads by day for rails_admin 0.0.1.
57
+ # (Defaults to the latest version if no version is specified.)
58
+ Gems.downloads 'rails_admin', '0.0.1'
59
+
60
+ # Return the number of downloads by day for coulda 0.6.3 for the past 90 days.
61
+ # (Defaults to the latest version if no version is specified.)
62
+ Gems.downloads 'coulda', '0.6.3'
54
63
 
55
- # List all gems that you own.
56
- puts Gems.gems
64
+ # Return the number of downloads by day for coulda 0.6.3 for the past year.
65
+ Gems.downloads 'coulda', '0.6.3', Date.today - 365, Date.today
57
66
 
58
67
  # View all owners of a gem that you own.
59
- puts Gems.owners 'gemcutter'
68
+ Gems.owners 'gemcutter'
60
69
 
61
70
  # Add an owner to a RubyGem you own, giving that user permission to manage it.
62
71
  Gems.add_owner 'josh@technicalpickles.com', 'gemcutter'
@@ -64,8 +73,8 @@ Ruby wrapper for the RubyGems.org API.
64
73
  # Remove a user's permission to manage a RubyGem you own.
65
74
  Gems.remove_owner 'josh@technicalpickles.com', 'gemcutter'
66
75
 
67
- # List the webhooks registered under your account.
68
- puts Gems.web_hooks
76
+ # Return all the webhooks registered under your account.
77
+ Gems.web_hooks
69
78
 
70
79
  # Add a webhook.
71
80
  Gems.add_web_hook 'rails', 'http://example.com'
@@ -76,18 +85,30 @@ Ruby wrapper for the RubyGems.org API.
76
85
  # Test fire a webhook.
77
86
  Gems.fire_web_hook 'rails', 'http://example.com'
78
87
 
79
- # Submit a gem to RubyGems.org.
80
- Gems.push File.new 'gemcutter-0.2.1.gem'
88
+ # Returns the 50 gems most recently added to RubyGems.org
89
+ Gems.latest
81
90
 
82
- # Remove a gem from RubyGems.org's index.
83
- # Defaults to the latest version if no version is specified.
84
- Gems.yank 'bills', '0.0.1'
91
+ # Returns the 50 most recently updated gems
92
+ Gems.just_updated
85
93
 
86
- # Update a previously yanked gem back into RubyGems.org's index.
87
- # Defaults to the latest version if no version is specified.
88
- Gems.unyank 'bills', '0.0.1'
94
+ # Retrieve your API key using HTTP basic authentication.
95
+ Gems.configure do |config|
96
+ config.username = 'nick@gemcutter.org'
97
+ config.password = 'schwwwwing'
98
+ end
99
+ Gems.api_key
100
+
101
+ # Return an array of gem dependency details for all versions of all the given gems.
102
+ Gems.dependencies ['rails', 'thor']
103
+
104
+ # The following methods require authentication.
105
+ # By default, we load your API key from ~/.gem/credentails
106
+ # You can override this default by specifying a custom API key.
107
+ Gems.configure do |config|
108
+ config.key '701243f217cdf23b1370c7b66b65ca97'
109
+ end
89
110
 
90
- ## <a name="contributing"></a>Contributing
111
+ ## Contributing
91
112
  In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.
92
113
 
93
114
  Here are some ways *you* can contribute:
@@ -97,31 +118,41 @@ Here are some ways *you* can contribute:
97
118
  * by suggesting new features
98
119
  * by writing or editing documentation
99
120
  * by writing specifications
100
- * by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
121
+ * by writing code (**no patch is too small**: fix typos, add comments, clean up
122
+ inconsistent whitespace)
101
123
  * by refactoring code
102
124
  * by closing [issues](https://github.com/rubygems/gems/issues)
103
125
  * by reviewing patches
104
126
 
105
- ## <a name="issues"></a>Submitting an Issue
106
- We use the [GitHub issue tracker](https://github.com/rubygems/gems/issues) to track bugs and
107
- features. Before submitting a bug report or feature request, check to make sure it hasn't already
108
- been submitted. You can indicate support for an existing issue by voting it up. When submitting a
109
- bug report, please include a [Gist](https://gist.github.com/) that includes a stack trace and any
110
- details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
111
- operating system. Ideally, a bug report should include a pull request with failing specs.
112
-
113
- ## <a name="pulls"></a>Submitting a Pull Request
114
- 1. Fork the project.
115
- 2. Create a topic branch.
116
- 3. Implement your feature or bug fix.
117
- 4. Add documentation for your feature or bug fix.
118
- 5. Run <tt>bundle exec rake doc:yard</tt>. If your changes are not 100% documented, go back to step 4.
119
- 6. Add specs for your feature or bug fix.
120
- 7. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 6.
121
- 8. Commit and push your changes.
122
- 9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
123
-
124
- ## <a name="versions"></a>Supported Ruby Versions
127
+ ## Submitting an Issue
128
+ We use the [GitHub issue tracker](https://github.com/rubygems/gems/issues) to
129
+ track bugs and features. Before submitting a bug report or feature request,
130
+ check to make sure it hasn't already been submitted. When submitting a bug
131
+ report, please include a [Gist](https://gist.github.com/) that includes a stack
132
+ trace and any details that may be necessary to reproduce the bug, including
133
+ your gem version, Ruby version, and operating system. Ideally, a bug report
134
+ should include a pull request with failing specs.
135
+
136
+ ## Submitting a Pull Request
137
+ 1. [Fork the repository.][fork]
138
+ 2. [Create a topic branch.][branch]
139
+ 3. Add specs for your unimplemented feature or bug fix.
140
+ 4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
141
+ 5. Implement your feature or bug fix.
142
+ 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
143
+ 7. Run `open coverage/index.html`. If your changes are not completely covered
144
+ by your tests, return to step 3.
145
+ 8. Add documentation for your feature or bug fix.
146
+ 9. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
147
+ back to step 8.
148
+ 10. Add, commit, and push your changes.
149
+ 11. [Submit a pull request.][pr]
150
+
151
+ [fork]: http://help.github.com/fork-a-repo/
152
+ [branch]: http://learn.github.com/p/branching.html
153
+ [pr]: http://help.github.com/send-pull-requests/
154
+
155
+ ## Supported Ruby Versions
125
156
  This library aims to support and is [tested against][travis] the following Ruby
126
157
  implementations:
127
158
 
@@ -130,11 +161,9 @@ implementations:
130
161
  * Ruby 1.9.3
131
162
  * [JRuby][]
132
163
  * [Rubinius][]
133
- * [Ruby Enterprise Edition][ree]
134
164
 
135
165
  [jruby]: http://www.jruby.org/
136
166
  [rubinius]: http://rubini.us/
137
- [ree]: http://www.rubyenterpriseedition.com/)
138
167
 
139
168
  If something doesn't work on one of these interpreters, it should be considered
140
169
  a bug.
@@ -150,7 +179,7 @@ implementation, you will be personally responsible for providing patches in a
150
179
  timely fashion. If critical issues for a particular implementation exist at the
151
180
  time of a major release, support for that Ruby version may be dropped.
152
181
 
153
- ## <a name="copyright"></a>Copyright
182
+ ## Copyright
154
183
  Copyright (c) 2011 Erik Michaels-Ober. See [LICENSE][] for details.
155
184
 
156
185
  [license]: https://github.com/rubygems/gems/blob/master/LICENSE.md
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env rake
2
-
3
1
  require 'bundler'
4
2
  Bundler::GemHelper.install_tasks
5
3
 
data/gems.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
  require File.expand_path('../lib/gems/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_development_dependency 'rake', '~> 0.9'
6
- gem.add_development_dependency 'rdiscount', '~> 1.6'
7
- gem.add_development_dependency 'rspec', '~> 2.6'
8
- gem.add_development_dependency 'simplecov', '~> 0.4'
9
- gem.add_development_dependency 'webmock', '~> 1.7'
10
- gem.add_development_dependency 'yard', '~> 0.7'
5
+ gem.add_development_dependency 'maruku'
6
+ gem.add_development_dependency 'rake'
7
+ gem.add_development_dependency 'rspec'
8
+ gem.add_development_dependency 'simplecov'
9
+ gem.add_development_dependency 'webmock'
10
+ gem.add_development_dependency 'yard'
11
11
  gem.authors = ["Erik Michaels-Ober"]
12
12
  gem.description = %q{Ruby wrapper for the RubyGems.org API}
13
13
  gem.email = ['sferik@gmail.com']
data/lib/gems/client.rb CHANGED
@@ -39,6 +39,63 @@ module Gems
39
39
  YAML.load(response)
40
40
  end
41
41
 
42
+ # List all gems that you own
43
+ #
44
+ # @authenticated true
45
+ # @param user_handle [String] The handle of a user.
46
+ # @return [Array]
47
+ # @example
48
+ # Gems.gems
49
+ def gems(user_handle=nil)
50
+ response = if user_handle
51
+ get("/api/v1/owners/#{user_handle}/gems.yaml")
52
+ else
53
+ get("/api/v1/gems.yaml")
54
+ end
55
+ YAML.load(response)
56
+ end
57
+
58
+ # Submit a gem to RubyGems.org
59
+ #
60
+ # @authenticated true
61
+ # @param gem [File] A built gem.
62
+ # @return [String]
63
+ # @example
64
+ # Gems.push File.new 'pkg/gemcutter-0.2.1.gem'
65
+ def push(gem)
66
+ post("/api/v1/gems", gem.read, 'application/octet-stream')
67
+ end
68
+
69
+ # Remove a gem from RubyGems.org's index
70
+ #
71
+ # @authenticated true
72
+ # @param gem_name [String] The name of a gem.
73
+ # @param gem_version [String] The version of a gem.
74
+ # @param options [Hash] A customizable set of options.
75
+ # @option options [String] :platform
76
+ # @return [String]
77
+ # @example
78
+ # Gems.yank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
79
+ def yank(gem_name, gem_version=nil, options={})
80
+ gem_version ||= info(gem_name)['version']
81
+ delete("/api/v1/gems/yank", options.merge(:gem_name => gem_name, :version => gem_version))
82
+ end
83
+
84
+ # Update a previously yanked gem back into RubyGems.org's index
85
+ #
86
+ # @authenticated true
87
+ # @param gem_name [String] The name of a gem.
88
+ # @param gem_version [String] The version of a gem.
89
+ # @param options [Hash] A customizable set of options.
90
+ # @option options [String] :platform
91
+ # @return [String]
92
+ # @example
93
+ # Gems.unyank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
94
+ def unyank(gem_name, gem_version=nil, options={})
95
+ gem_version ||= info(gem_name)['version']
96
+ put("/api/v1/gems/unyank", options.merge(:gem_name => gem_name, :version => gem_version))
97
+ end
98
+
42
99
  # Returns an array of gem version details
43
100
  #
44
101
  # @authenticated false
@@ -58,26 +115,37 @@ module Gems
58
115
  # @param gem_version [String] The version of a gem.
59
116
  # @return [Hash]
60
117
  # @example
61
- # Gems.total_downloads 'rails_admin', '0.0.0'
118
+ # Gems.total_downloads 'rails_admin', '0.0.1'
62
119
  def total_downloads(gem_name=nil, gem_version=nil)
63
- if gem_name
120
+ response = if gem_name
64
121
  gem_version ||= info(gem_name)['version']
65
- response = get("/api/v1/downloads/#{gem_name}-#{gem_version}.yaml")
122
+ get("/api/v1/downloads/#{gem_name}-#{gem_version}.yaml")
66
123
  else
67
- response = get("/api/v1/downloads.yaml")
124
+ get("/api/v1/downloads.yaml")
68
125
  end
69
126
  YAML.load(response)
70
127
  end
71
128
 
72
- # Returns an array of the most downloaded gem versions of all time
129
+ # Returns an array containing the top 50 downloaded gem versions for today
73
130
  #
74
131
  # @authenticated false
75
- # @return [Hash]
132
+ # @return [Array]
133
+ # @example
134
+ # Gems.most_downloaded_today
135
+ def most_downloaded_today
136
+ response = get("/api/v1/downloads/top.yaml")
137
+ YAML.load(response)[:gems]
138
+ end
139
+
140
+ # Returns an array containing the top 50 downloaded gem versions of all time
141
+ #
142
+ # @authenticated false
143
+ # @return [Array]
76
144
  # @example
77
145
  # Gems.most_downloaded
78
146
  def most_downloaded
79
147
  response = get("/api/v1/downloads/all.yaml")
80
- YAML.load(response)
148
+ YAML.load(response)[:gems]
81
149
  end
82
150
 
83
151
  # Returns the number of downloads by day for a particular gem version
@@ -100,43 +168,6 @@ module Gems
100
168
  YAML.load(response)
101
169
  end
102
170
 
103
- # Returns an array of hashes for all versions of given gems
104
- #
105
- # @authenticated false
106
- # @param gems [Array] A list of gem names
107
- # @return [Array]
108
- # @example
109
- # Gems.dependencies 'rails', 'thor'
110
- def dependencies(*gems)
111
- response = get('/api/v1/dependencies', {:gems => gems.join(',')})
112
- Marshal.load(response)
113
- end
114
-
115
- # Retrieve your API key using HTTP basic auth
116
- #
117
- # @authenticated true
118
- # @return [String]
119
- # @example
120
- # Gems.configure do |config|
121
- # config.username = 'nick@gemcutter.org'
122
- # config.password = 'schwwwwing'
123
- # end
124
- # Gems.api_key
125
- def api_key
126
- get('/api/v1/api_key')
127
- end
128
-
129
- # List all gems that you own
130
- #
131
- # @authenticated true
132
- # @return [Array]
133
- # @example
134
- # Gems.gems
135
- def gems
136
- response = get("/api/v1/gems.yaml")
137
- YAML.load(response)
138
- end
139
-
140
171
  # View all owners of a gem that you own
141
172
  #
142
173
  # @authenticated true
@@ -220,48 +251,7 @@ module Gems
220
251
  post("/api/v1/web_hooks/fire", {:gem_name => gem_name, :url => url})
221
252
  end
222
253
 
223
- # Submit a gem to RubyGems.org
224
- #
225
- # @authenticated true
226
- # @param gem [File] A built gem.
227
- # @return [String]
228
- # @example
229
- # Gems.push File.new 'pkg/gemcutter-0.2.1.gem'
230
- def push(gem)
231
- post("/api/v1/gems", gem.read, 'application/octet-stream')
232
- end
233
-
234
- # Remove a gem from RubyGems.org's index
235
- #
236
- # @authenticated true
237
- # @param gem_name [String] The name of a gem.
238
- # @param gem_version [String] The version of a gem.
239
- # @param options [Hash] A customizable set of options.
240
- # @option options [String] :platform
241
- # @return [String]
242
- # @example
243
- # Gems.yank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
244
- def yank(gem_name, gem_version=nil, options={})
245
- gem_version ||= info(gem_name)['version']
246
- delete("/api/v1/gems/yank", options.merge(:gem_name => gem_name, :version => gem_version))
247
- end
248
-
249
- # Update a previously yanked gem back into RubyGems.org's index
250
- #
251
- # @authenticated true
252
- # @param gem_name [String] The name of a gem.
253
- # @param gem_version [String] The version of a gem.
254
- # @param options [Hash] A customizable set of options.
255
- # @option options [String] :platform
256
- # @return [String]
257
- # @example
258
- # Gems.unyank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
259
- def unyank(gem_name, gem_version=nil, options={})
260
- gem_version ||= info(gem_name)['version']
261
- put("/api/v1/gems/unyank", options.merge(:gem_name => gem_name, :version => gem_version))
262
- end
263
-
264
- # Pulls the 50 gems most recently added to RubyGems.org (for the first time). Returns an array of the XML or JSON representation of the gems
254
+ # Returns the 50 gems most recently added to RubyGems.org (for the first time)
265
255
  #
266
256
  # @authenticated false
267
257
  # @param options [Hash] A customizable set of options.
@@ -273,7 +263,7 @@ module Gems
273
263
  YAML.load(response)
274
264
  end
275
265
 
276
- # Pulls the 50 most recently updated gems. Returns an array of the XML or JSON representation of the gem versions
266
+ # Returns the 50 most recently updated gems
277
267
  #
278
268
  # @authenticated false
279
269
  # @param options [Hash] A customizable set of options.
@@ -285,5 +275,31 @@ module Gems
285
275
  YAML.load(response)
286
276
  end
287
277
 
278
+ # Retrieve your API key using HTTP basic auth
279
+ #
280
+ # @authenticated true
281
+ # @return [String]
282
+ # @example
283
+ # Gems.configure do |config|
284
+ # config.username = 'nick@gemcutter.org'
285
+ # config.password = 'schwwwwing'
286
+ # end
287
+ # Gems.api_key
288
+ def api_key
289
+ get('/api/v1/api_key')
290
+ end
291
+
292
+ # Returns an array of hashes for all versions of given gems
293
+ #
294
+ # @authenticated false
295
+ # @param gems [Array] A list of gem names
296
+ # @return [Array]
297
+ # @example
298
+ # Gems.dependencies 'rails', 'thor'
299
+ def dependencies(*gems)
300
+ response = get('/api/v1/dependencies', {:gems => gems.join(',')})
301
+ Marshal.load(response)
302
+ end
303
+
288
304
  end
289
305
  end