gems 0.8.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +3 -3
- data/README.md +11 -23
- data/gems.gemspec +12 -16
- data/lib/gems.rb +7 -3
- data/lib/gems/client.rb +47 -60
- data/lib/gems/configuration.rb +7 -7
- data/lib/gems/request.rb +26 -22
- data/lib/gems/version.rb +3 -3
- metadata +28 -105
- data.tar.gz.sig +0 -2
- data/Rakefile +0 -11
- data/spec/fixtures/add_owner +0 -1
- data/spec/fixtures/add_web_hook +0 -1
- data/spec/fixtures/api_key +0 -1
- data/spec/fixtures/dependencies +0 -0
- data/spec/fixtures/downloads.yaml +0 -91
- data/spec/fixtures/fire_web_hook +0 -1
- data/spec/fixtures/gems-0.0.8.gem +0 -0
- data/spec/fixtures/gems.yaml +0 -1072
- data/spec/fixtures/just_updated.yaml +0 -1376
- data/spec/fixtures/latest.yaml +0 -1098
- data/spec/fixtures/most_downloaded.yaml +0 -20
- data/spec/fixtures/most_downloaded_today.yaml +0 -1053
- data/spec/fixtures/owners.yaml +0 -2
- data/spec/fixtures/push +0 -1
- data/spec/fixtures/rails.yaml +0 -33
- data/spec/fixtures/rails_admin-0.0.0.yaml +0 -3
- data/spec/fixtures/remove_owner +0 -1
- data/spec/fixtures/remove_web_hook +0 -1
- data/spec/fixtures/reverse_dependencies_short.yaml +0 -70
- data/spec/fixtures/script_helpers.yaml +0 -17
- data/spec/fixtures/search.yaml +0 -898
- data/spec/fixtures/total_downloads.yaml +0 -2
- data/spec/fixtures/unyank +0 -1
- data/spec/fixtures/web_hooks.yaml +0 -4
- data/spec/fixtures/yank +0 -1
- data/spec/gems/client_spec.rb +0 -432
- data/spec/gems/request_spec.rb +0 -31
- data/spec/gems_spec.rb +0 -73
- data/spec/helper.rb +0 -64
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27bd2da368ca93d2b8ac32fd25465987368be2b0
|
4
|
+
data.tar.gz: c53afd6178dfab27ca122e9b144b441e71f69a47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2bd0758a749c07093478dea04fe356f39e4be8158892b9a97f7b4e7bdd965cfd4b4cd28bdc422d5a2471acb88663cdc56883286f541032e9c639cbe6e15d65d9
|
7
|
+
data.tar.gz: 8a60367eec5ed9cd320909e8cc706091b0e4aaed76f19b9f95f9673f9b2d4fa2161638af876390bbb0d2bbf4c91ddb10c5b3537d1d93608130a00ab0ec761cf5
|
data/CONTRIBUTING.md
CHANGED
@@ -28,12 +28,12 @@ Ideally, a bug report should include a pull request with failing specs.
|
|
28
28
|
3. Add specs for your unimplemented feature or bug fix.
|
29
29
|
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
30
30
|
5. Implement your feature or bug fix.
|
31
|
-
6. Run `bundle exec rake
|
31
|
+
6. Run `bundle exec rake`. If your specs fail, return to step 5.
|
32
32
|
7. Run `open coverage/index.html`. If your changes are not completely covered
|
33
33
|
by your tests, return to step 3.
|
34
34
|
8. Add documentation for your feature or bug fix.
|
35
|
-
9. Run `bundle exec rake
|
36
|
-
back to step 8.
|
35
|
+
9. Run `bundle exec rake verify_measurements`. If your changes are not 100%
|
36
|
+
documented, go back to step 8.
|
37
37
|
10. Add, commit, and push your changes.
|
38
38
|
11. [Submit a pull request.][pr]
|
39
39
|
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Gems
|
2
2
|
|
3
|
-
[![Gem Version](
|
4
|
-
[![Build Status](
|
5
|
-
[![Dependency Status](
|
6
|
-
[![Code Climate](
|
7
|
-
[![Coverage Status](
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/gems.svg)][gem]
|
4
|
+
[![Build Status](http://img.shields.io/travis/rubygems/gems.svg)][travis]
|
5
|
+
[![Dependency Status](http://img.shields.io/gemnasium/rubygems/gems.svg)][gemnasium]
|
6
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/rubygems/gems.svg)][codeclimate]
|
7
|
+
[![Coverage Status](http://img.shields.io/coveralls/rubygems/gems.svg)][coveralls]
|
8
8
|
|
9
9
|
[gem]: https://rubygems.org/gems/gems
|
10
10
|
[travis]: http://travis-ci.org/rubygems/gems
|
@@ -17,16 +17,6 @@ Ruby wrapper for the RubyGems.org API.
|
|
17
17
|
## Installation
|
18
18
|
gem install gems
|
19
19
|
|
20
|
-
To ensure the code you're installing hasn't been tampered with, it's
|
21
|
-
recommended that you verify the signature. To do this, you need to add my
|
22
|
-
public key as a trusted certificate (you only need to do this once):
|
23
|
-
|
24
|
-
gem cert --add <(curl -Ls https://raw.github.com/rubygems/gems/master/certs/sferik.pem)
|
25
|
-
|
26
|
-
Then, install the gem with the high security trust policy:
|
27
|
-
|
28
|
-
gem install gems -P HighSecurity
|
29
|
-
|
30
20
|
## Documentation
|
31
21
|
[http://rdoc.info/gems/gems](http://rdoc.info/gems/gems)
|
32
22
|
|
@@ -119,25 +109,23 @@ Then, install the gem with the high security trust policy:
|
|
119
109
|
Gems.dependencies ['rails', 'thor']
|
120
110
|
|
121
111
|
# The following methods require authentication.
|
122
|
-
# By default, we load your API key from ~/.gem/
|
112
|
+
# By default, we load your API key from ~/.gem/credentials
|
123
113
|
# You can override this default by specifying a custom API key.
|
124
114
|
Gems.configure do |config|
|
125
|
-
config.key '701243f217cdf23b1370c7b66b65ca97'
|
115
|
+
config.key = '701243f217cdf23b1370c7b66b65ca97'
|
126
116
|
end
|
127
117
|
|
128
118
|
## Supported Ruby Versions
|
129
119
|
This library aims to support and is [tested against][travis] the following Ruby
|
130
120
|
implementations:
|
131
121
|
|
132
|
-
* Ruby 1
|
133
|
-
* Ruby
|
134
|
-
* Ruby
|
135
|
-
* Ruby 2.
|
122
|
+
* Ruby 2.1
|
123
|
+
* Ruby 2.2
|
124
|
+
* Ruby 2.3
|
125
|
+
* Ruby 2.4
|
136
126
|
* [JRuby][]
|
137
|
-
* [Rubinius][]
|
138
127
|
|
139
128
|
[jruby]: http://www.jruby.org/
|
140
|
-
[rubinius]: http://rubini.us/
|
141
129
|
|
142
130
|
If something doesn't work on one of these interpreters, it's a bug.
|
143
131
|
|
data/gems.gemspec
CHANGED
@@ -4,21 +4,17 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'gems/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
+
spec.add_dependency 'json'
|
7
8
|
spec.add_development_dependency 'bundler', '~> 1.0'
|
8
|
-
spec.authors
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
|
21
|
-
spec.summary = spec.description
|
22
|
-
spec.test_files = Dir.glob("spec/**/*")
|
23
|
-
spec.version = Gems::VERSION
|
9
|
+
spec.authors = ['Erik Michaels-Ober']
|
10
|
+
spec.description = 'Ruby wrapper for the RubyGems.org API'
|
11
|
+
spec.email = ['sferik@gmail.com']
|
12
|
+
spec.files = %w(.yardopts CONTRIBUTING.md LICENSE.md README.md gems.gemspec) + Dir['lib/**/*.rb']
|
13
|
+
spec.homepage = 'https://github.com/rubygems/gems'
|
14
|
+
spec.licenses = %w(MIT)
|
15
|
+
spec.name = 'gems'
|
16
|
+
spec.require_paths = %w(lib)
|
17
|
+
spec.required_ruby_version = '>= 2.1.9'
|
18
|
+
spec.summary = spec.description
|
19
|
+
spec.version = Gems::VERSION
|
24
20
|
end
|
data/lib/gems.rb
CHANGED
@@ -7,7 +7,7 @@ module Gems
|
|
7
7
|
# Alias for Gems::Client.new
|
8
8
|
#
|
9
9
|
# @return [Gems::Client]
|
10
|
-
def new(options={})
|
10
|
+
def new(options = {})
|
11
11
|
Gems::Client.new(options)
|
12
12
|
end
|
13
13
|
|
@@ -17,8 +17,12 @@ module Gems
|
|
17
17
|
new.send(method, *args, &block)
|
18
18
|
end
|
19
19
|
|
20
|
-
def respond_to?(
|
21
|
-
new.respond_to?(
|
20
|
+
def respond_to?(method_name, include_private = false)
|
21
|
+
new.respond_to?(method_name, include_private) || super(method_name, include_private)
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to_missing?(method_name, include_private = false)
|
25
|
+
new.respond_to?(method_name, include_private) || super(method_name, include_private)
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/gems/client.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'gems/configuration'
|
3
3
|
require 'gems/request'
|
4
|
-
require '
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
module Gems
|
7
7
|
class Client
|
8
8
|
include Gems::Request
|
9
|
-
attr_accessor
|
9
|
+
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
|
10
10
|
|
11
|
-
def initialize(options={})
|
11
|
+
def initialize(options = {})
|
12
12
|
options = Gems.options.merge(options)
|
13
13
|
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
14
14
|
send("#{key}=", options[key])
|
@@ -23,8 +23,8 @@ module Gems
|
|
23
23
|
# @example
|
24
24
|
# Gems.info 'rails'
|
25
25
|
def info(gem_name)
|
26
|
-
response = get("/api/v1/gems/#{gem_name}.
|
27
|
-
|
26
|
+
response = get("/api/v1/gems/#{gem_name}.json")
|
27
|
+
JSON.parse(response)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Returns an array of active gems that match the query
|
@@ -35,8 +35,8 @@ module Gems
|
|
35
35
|
# @example
|
36
36
|
# Gems.search 'cucumber'
|
37
37
|
def search(query)
|
38
|
-
response = get(
|
39
|
-
|
38
|
+
response = get('/api/v1/search.json', :query => query)
|
39
|
+
JSON.parse(response)
|
40
40
|
end
|
41
41
|
|
42
42
|
# List all gems that you own
|
@@ -46,13 +46,9 @@ module Gems
|
|
46
46
|
# @return [Array]
|
47
47
|
# @example
|
48
48
|
# Gems.gems
|
49
|
-
def gems(user_handle=nil)
|
50
|
-
response =
|
51
|
-
|
52
|
-
else
|
53
|
-
get("/api/v1/gems.yaml")
|
54
|
-
end
|
55
|
-
YAML.load(response)
|
49
|
+
def gems(user_handle = nil)
|
50
|
+
response = user_handle ? get("/api/v1/owners/#{user_handle}/gems.json") : get('/api/v1/gems.json')
|
51
|
+
JSON.parse(response)
|
56
52
|
end
|
57
53
|
|
58
54
|
# Submit a gem to RubyGems.org or another host
|
@@ -63,8 +59,8 @@ module Gems
|
|
63
59
|
# @return [String]
|
64
60
|
# @example
|
65
61
|
# Gems.push File.new 'pkg/gemcutter-0.2.1.gem'
|
66
|
-
def push(gem, host=Configuration::DEFAULT_HOST)
|
67
|
-
post(
|
62
|
+
def push(gem, host = Configuration::DEFAULT_HOST)
|
63
|
+
post('/api/v1/gems', gem.read, 'application/octet-stream', host)
|
68
64
|
end
|
69
65
|
|
70
66
|
# Remove a gem from RubyGems.org's index
|
@@ -77,9 +73,9 @@ module Gems
|
|
77
73
|
# @return [String]
|
78
74
|
# @example
|
79
75
|
# Gems.yank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
|
80
|
-
def yank(gem_name, gem_version=nil, options={})
|
76
|
+
def yank(gem_name, gem_version = nil, options = {})
|
81
77
|
gem_version ||= info(gem_name)['version']
|
82
|
-
delete(
|
78
|
+
delete('/api/v1/gems/yank', options.merge(:gem_name => gem_name, :version => gem_version))
|
83
79
|
end
|
84
80
|
|
85
81
|
# Update a previously yanked gem back into RubyGems.org's index
|
@@ -92,9 +88,9 @@ module Gems
|
|
92
88
|
# @return [String]
|
93
89
|
# @example
|
94
90
|
# Gems.unyank "gemcutter", "0.2.1", {:platform => "x86-darwin-10"}
|
95
|
-
def unyank(gem_name, gem_version=nil, options={})
|
91
|
+
def unyank(gem_name, gem_version = nil, options = {})
|
96
92
|
gem_version ||= info(gem_name)['version']
|
97
|
-
put(
|
93
|
+
put('/api/v1/gems/unyank', options.merge(:gem_name => gem_name, :version => gem_version))
|
98
94
|
end
|
99
95
|
|
100
96
|
# Returns an array of gem version details
|
@@ -105,8 +101,8 @@ module Gems
|
|
105
101
|
# @example
|
106
102
|
# Gems.versions 'coulda'
|
107
103
|
def versions(gem_name)
|
108
|
-
response = get("/api/v1/versions/#{gem_name}.
|
109
|
-
|
104
|
+
response = get("/api/v1/versions/#{gem_name}.json")
|
105
|
+
JSON.parse(response)
|
110
106
|
end
|
111
107
|
|
112
108
|
# Returns the total number of downloads for a particular gem
|
@@ -117,14 +113,9 @@ module Gems
|
|
117
113
|
# @return [Hash]
|
118
114
|
# @example
|
119
115
|
# Gems.total_downloads 'rails_admin', '0.0.1'
|
120
|
-
def total_downloads(gem_name=nil, gem_version=nil)
|
121
|
-
response =
|
122
|
-
|
123
|
-
get("/api/v1/downloads/#{gem_name}-#{gem_version}.yaml")
|
124
|
-
else
|
125
|
-
get("/api/v1/downloads.yaml")
|
126
|
-
end
|
127
|
-
YAML.load(response)
|
116
|
+
def total_downloads(gem_name = nil, gem_version = nil)
|
117
|
+
response = gem_name ? get("/api/v1/downloads/#{gem_name}-#{gem_version || info(gem_name)['version']}.json") : get('/api/v1/downloads.json')
|
118
|
+
JSON.parse(response, :symbolize_names => true)
|
128
119
|
end
|
129
120
|
|
130
121
|
# Returns an array containing the top 50 downloaded gem versions for today
|
@@ -134,8 +125,8 @@ module Gems
|
|
134
125
|
# @example
|
135
126
|
# Gems.most_downloaded_today
|
136
127
|
def most_downloaded_today
|
137
|
-
response = get(
|
138
|
-
|
128
|
+
response = get('/api/v1/downloads/top.json')
|
129
|
+
JSON.parse(response)['gems']
|
139
130
|
end
|
140
131
|
|
141
132
|
# Returns an array containing the top 50 downloaded gem versions of all time
|
@@ -145,8 +136,8 @@ module Gems
|
|
145
136
|
# @example
|
146
137
|
# Gems.most_downloaded
|
147
138
|
def most_downloaded
|
148
|
-
response = get(
|
149
|
-
|
139
|
+
response = get('/api/v1/downloads/all.json')
|
140
|
+
JSON.parse(response)['gems']
|
150
141
|
end
|
151
142
|
|
152
143
|
# Returns the number of downloads by day for a particular gem version
|
@@ -159,14 +150,10 @@ module Gems
|
|
159
150
|
# @return [Hash]
|
160
151
|
# @example
|
161
152
|
# Gems.downloads 'coulda', '0.6.3', Date.today - 30, Date.today
|
162
|
-
def downloads(gem_name, gem_version=nil, from=nil, to=Date.today)
|
153
|
+
def downloads(gem_name, gem_version = nil, from = nil, to = Date.today)
|
163
154
|
gem_version ||= info(gem_name)['version']
|
164
|
-
response =
|
165
|
-
|
166
|
-
else
|
167
|
-
get("/api/v1/versions/#{gem_name}-#{gem_version}/downloads.yaml")
|
168
|
-
end
|
169
|
-
YAML.load(response)
|
155
|
+
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")
|
156
|
+
JSON.parse(response)
|
170
157
|
end
|
171
158
|
|
172
159
|
# View all owners of a gem that you own
|
@@ -177,8 +164,8 @@ module Gems
|
|
177
164
|
# @example
|
178
165
|
# Gems.owners 'gemcutter'
|
179
166
|
def owners(gem_name)
|
180
|
-
response = get("/api/v1/gems/#{gem_name}/owners.
|
181
|
-
|
167
|
+
response = get("/api/v1/gems/#{gem_name}/owners.json")
|
168
|
+
JSON.parse(response)
|
182
169
|
end
|
183
170
|
|
184
171
|
# Add an owner to a RubyGem you own, giving that user permission to manage it
|
@@ -190,7 +177,7 @@ module Gems
|
|
190
177
|
# @example
|
191
178
|
# Gems.add_owner 'gemcutter', 'josh@technicalpickles.com'
|
192
179
|
def add_owner(gem_name, owner)
|
193
|
-
post("/api/v1/gems/#{gem_name}/owners",
|
180
|
+
post("/api/v1/gems/#{gem_name}/owners", :email => owner)
|
194
181
|
end
|
195
182
|
|
196
183
|
# Remove a user's permission to manage a RubyGem you own
|
@@ -202,7 +189,7 @@ module Gems
|
|
202
189
|
# @example
|
203
190
|
# Gems.remove_owner 'gemcutter', 'josh@technicalpickles.com'
|
204
191
|
def remove_owner(gem_name, owner)
|
205
|
-
delete("/api/v1/gems/#{gem_name}/owners",
|
192
|
+
delete("/api/v1/gems/#{gem_name}/owners", :email => owner)
|
206
193
|
end
|
207
194
|
|
208
195
|
# List the webhooks registered under your account
|
@@ -212,8 +199,8 @@ module Gems
|
|
212
199
|
# @example
|
213
200
|
# Gems.web_hooks
|
214
201
|
def web_hooks
|
215
|
-
response = get(
|
216
|
-
|
202
|
+
response = get('/api/v1/web_hooks.json')
|
203
|
+
JSON.parse(response)
|
217
204
|
end
|
218
205
|
|
219
206
|
# Create a webhook
|
@@ -225,7 +212,7 @@ module Gems
|
|
225
212
|
# @example
|
226
213
|
# Gems.add_web_hook 'rails', 'http://example.com'
|
227
214
|
def add_web_hook(gem_name, url)
|
228
|
-
post(
|
215
|
+
post('/api/v1/web_hooks', :gem_name => gem_name, :url => url)
|
229
216
|
end
|
230
217
|
|
231
218
|
# Remove a webhook
|
@@ -237,7 +224,7 @@ module Gems
|
|
237
224
|
# @example
|
238
225
|
# Gems.remove_web_hook 'rails', 'http://example.com'
|
239
226
|
def remove_web_hook(gem_name, url)
|
240
|
-
delete(
|
227
|
+
delete('/api/v1/web_hooks/remove', :gem_name => gem_name, :url => url)
|
241
228
|
end
|
242
229
|
|
243
230
|
# Test fire a webhook
|
@@ -249,7 +236,7 @@ module Gems
|
|
249
236
|
# @example
|
250
237
|
# Gems.fire_web_hook 'rails', 'http://example.com'
|
251
238
|
def fire_web_hook(gem_name, url)
|
252
|
-
post(
|
239
|
+
post('/api/v1/web_hooks/fire', :gem_name => gem_name, :url => url)
|
253
240
|
end
|
254
241
|
|
255
242
|
# Returns the 50 gems most recently added to RubyGems.org (for the first time)
|
@@ -259,9 +246,9 @@ module Gems
|
|
259
246
|
# @return [Array]
|
260
247
|
# @example
|
261
248
|
# Gem.latest
|
262
|
-
def latest(options={})
|
263
|
-
response = get(
|
264
|
-
|
249
|
+
def latest(options = {})
|
250
|
+
response = get('/api/v1/activity/latest.json', options)
|
251
|
+
JSON.parse(response)
|
265
252
|
end
|
266
253
|
|
267
254
|
# Returns the 50 most recently updated gems
|
@@ -271,9 +258,9 @@ module Gems
|
|
271
258
|
# @return [Array]
|
272
259
|
# @example
|
273
260
|
# Gem.just_updated
|
274
|
-
def just_updated(options={})
|
275
|
-
response = get(
|
276
|
-
|
261
|
+
def just_updated(options = {})
|
262
|
+
response = get('/api/v1/activity/just_updated.json', options)
|
263
|
+
JSON.parse(response)
|
277
264
|
end
|
278
265
|
|
279
266
|
# Retrieve your API key using HTTP basic auth
|
@@ -298,7 +285,7 @@ module Gems
|
|
298
285
|
# @example
|
299
286
|
# Gems.dependencies 'rails', 'thor'
|
300
287
|
def dependencies(*gems)
|
301
|
-
response = get('/api/v1/dependencies',
|
288
|
+
response = get('/api/v1/dependencies', :gems => gems.join(','))
|
302
289
|
Marshal.load(response)
|
303
290
|
end
|
304
291
|
|
@@ -310,9 +297,9 @@ module Gems
|
|
310
297
|
# @return [Array]
|
311
298
|
# @example
|
312
299
|
# Gems.reverse_dependencies 'money'
|
313
|
-
def reverse_dependencies(gem_name, options={})
|
314
|
-
response = get("/api/v1/gems/#{gem_name}/reverse_dependencies.
|
315
|
-
|
300
|
+
def reverse_dependencies(gem_name, options = {})
|
301
|
+
response = get("/api/v1/gems/#{gem_name}/reverse_dependencies.json", options)
|
302
|
+
JSON.parse(response)
|
316
303
|
end
|
317
304
|
end
|
318
305
|
end
|
data/lib/gems/configuration.rb
CHANGED
@@ -11,18 +11,18 @@ module Gems
|
|
11
11
|
:password,
|
12
12
|
:user_agent,
|
13
13
|
:username,
|
14
|
-
]
|
14
|
+
].freeze
|
15
15
|
|
16
16
|
# Set the default API endpoint
|
17
|
-
DEFAULT_HOST = ENV['RUBYGEMS_HOST'] ? ENV['RUBYGEMS_HOST'] :
|
17
|
+
DEFAULT_HOST = ENV['RUBYGEMS_HOST'] ? ENV['RUBYGEMS_HOST'] : 'https://rubygems.org'
|
18
18
|
|
19
19
|
# Set the default credentials
|
20
20
|
DEFAULT_KEY = Gem.configuration.rubygems_api_key
|
21
21
|
|
22
22
|
# Set the default 'User-Agent' HTTP header
|
23
|
-
DEFAULT_USER_AGENT = "Gems #{Gems::VERSION}"
|
23
|
+
DEFAULT_USER_AGENT = "Gems #{Gems::VERSION}".freeze
|
24
24
|
|
25
|
-
attr_accessor
|
25
|
+
attr_accessor(*VALID_OPTIONS_KEYS)
|
26
26
|
|
27
27
|
# When this module is extended, set all configuration options to their default values
|
28
28
|
def self.extended(base)
|
@@ -37,17 +37,17 @@ module Gems
|
|
37
37
|
# Create a hash of options and their values
|
38
38
|
def options
|
39
39
|
options = {}
|
40
|
-
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
|
40
|
+
VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
|
41
41
|
options
|
42
42
|
end
|
43
43
|
|
44
44
|
# Reset all configuration options to defaults
|
45
45
|
def reset
|
46
|
+
self.username = nil
|
47
|
+
self.password = nil
|
46
48
|
self.host = DEFAULT_HOST
|
47
49
|
self.key = DEFAULT_KEY
|
48
|
-
self.password = nil
|
49
50
|
self.user_agent = DEFAULT_USER_AGENT
|
50
|
-
self.username = nil
|
51
51
|
self
|
52
52
|
end
|
53
53
|
end
|