gems 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -3
- data/README.md +1 -1
- data/lib/gems/request.rb +15 -3
- data/lib/gems/version.rb +15 -1
- data/spec/gems/request_spec.rb +31 -0
- metadata +4 -8
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
h����(�#�7S0
|
3
|
-
sm���B5�;��n����ӫ��A&OfwF|a`d���7���������K�-䩡����DF$+�/V=@N�''��xMJ"���5Z�V�m9�jyjX�mC��'����9\��k
|
1
|
+
Nn�K ,r��aiAY"�K�n�<�a��:�}kf��s�xR)α09�:o�Ƣ�n������PP�I�;$�no��b�!��` .���Ɗ��4�rsu�Q�T)n�?c<W��V��E05Tӗ��.��XD�V�?D�%v7�Aw���+2Թ���Em2����=熬��L��% /؛�Sjn2:��gi��iP/aD�ċ��C�D�[%��W1A���64��c`�)lҺ�u�+kv)�����
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ To ensure the code you're installing hasn't been tampered with, it's
|
|
21
21
|
recommended that you verify the signature. To do this, you need to add my
|
22
22
|
public key as a trusted certificate (you only need to do this once):
|
23
23
|
|
24
|
-
gem cert --add <(curl -Ls https://
|
24
|
+
gem cert --add <(curl -Ls https://raw.github.com/rubygems/gems/master/certs/sferik.pem)
|
25
25
|
|
26
26
|
Then, install the gem with the high security trust policy:
|
27
27
|
|
data/lib/gems/request.rb
CHANGED
@@ -22,9 +22,9 @@ module Gems
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def request(method, path, data, content_type)
|
25
|
+
def request(method, path, data, content_type, request_host = host)
|
26
26
|
path = [path, hash_to_query_string(data)[/.+/]].compact.join('?') if [:delete, :get].include? method
|
27
|
-
uri = URI.parse [
|
27
|
+
uri = URI.parse [request_host, path].join
|
28
28
|
request_class = Net::HTTP.const_get method.to_s.capitalize
|
29
29
|
request = request_class.new uri.request_uri
|
30
30
|
request.add_field 'Authorization', key if key
|
@@ -48,7 +48,7 @@ module Gems
|
|
48
48
|
end
|
49
49
|
connection.start
|
50
50
|
response = connection.request request
|
51
|
-
response
|
51
|
+
body_from_response(response, method, content_type)
|
52
52
|
end
|
53
53
|
|
54
54
|
def hash_to_query_string(hash)
|
@@ -57,5 +57,17 @@ module Gems
|
|
57
57
|
query_string << "#{URI.encode(key.to_s)}=#{URI.encode(hash[key])}"
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
def body_from_response(response, method, content_type)
|
62
|
+
case response
|
63
|
+
when Net::HTTPRedirection
|
64
|
+
redirect_url = response['location']
|
65
|
+
uri = URI.parse(redirect_url)
|
66
|
+
host_with_scheme = [uri.scheme,uri.host].join('://')
|
67
|
+
request(method, uri.request_uri, {}, content_type, host_with_scheme)
|
68
|
+
else
|
69
|
+
response.body
|
70
|
+
end
|
71
|
+
end
|
60
72
|
end
|
61
73
|
end
|
data/lib/gems/version.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
module Gems
|
2
|
-
|
2
|
+
class Version
|
3
|
+
MAJOR = 0 unless defined? Gems::Version::MAJOR
|
4
|
+
MINOR = 8 unless defined? Gems::Version::MINOR
|
5
|
+
PATCH = 2 unless defined? Gems::Version::PATCH
|
6
|
+
PRE = nil unless defined? Gems::Version::PRE
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# @return [String]
|
10
|
+
def to_s
|
11
|
+
[MAJOR, MINOR, PATCH, PRE].compact.join('.')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
VERSION = Version.to_s
|
3
17
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Gems::Request do
|
4
|
+
after do
|
5
|
+
Gems.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#get with redirect" do
|
9
|
+
before do
|
10
|
+
# request_uri = URI.parse("https://rubygems.org/api/v1/dependencies?gems=rails,thor")
|
11
|
+
response_body = %q(<html>\r\n<head><title>302 Found</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>302 Found</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n)
|
12
|
+
response_code = "302"
|
13
|
+
response_location = "https://bundler.rubygems.org/api/v1/dependencies?gems=rails,thor"
|
14
|
+
|
15
|
+
stub_get("/api/v1/dependencies").
|
16
|
+
with(:query => {"gems" => "rails,thor"}).
|
17
|
+
to_return(:body => response_body, :status => 302, :headers => {:location => response_location})
|
18
|
+
stub_request(:get, "https://bundler.rubygems.org/api/v1/dependencies").
|
19
|
+
with(:query => {"gems" => "rails,thor"}).
|
20
|
+
to_return(:body => fixture('dependencies'), :status => 200, :headers => {})
|
21
|
+
|
22
|
+
end
|
23
|
+
it "returns an array of hashes for all versions of given gems" do
|
24
|
+
dependencies = Gems.dependencies 'rails', 'thor'
|
25
|
+
expect(a_get("/api/v1/dependencies").with(:query => {"gems" => "rails,thor"})).to have_been_made
|
26
|
+
expect(a_get("https://bundler.rubygems.org/api/v1/dependencies").with(:query => {"gems" => "rails,thor"})).to have_been_made
|
27
|
+
expect(dependencies.first[:number]).to eq "3.0.9"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
U0xxV3ZRUnNCbHlwSGZoczZKSnVMbHlaUEdoVTNSL3YKU2YzbFZLcEJDV2dS
|
37
37
|
cEdUdnk0NVhWcEIrNTl5MzNQSm1FdVExUFRFT1l2UXlhbzlVS01BQWFBTi83
|
38
38
|
cVdRdGpsMApobHc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
39
|
-
date: 2013-
|
39
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- spec/fixtures/web_hooks.yaml
|
99
99
|
- spec/fixtures/yank
|
100
100
|
- spec/gems/client_spec.rb
|
101
|
+
- spec/gems/request_spec.rb
|
101
102
|
- spec/gems_spec.rb
|
102
103
|
- spec/helper.rb
|
103
104
|
homepage: https://github.com/rubygems/gems
|
@@ -113,18 +114,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
114
|
- - ! '>='
|
114
115
|
- !ruby/object:Gem::Version
|
115
116
|
version: '0'
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
hash: -201331315228927799
|
119
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
118
|
none: false
|
121
119
|
requirements:
|
122
120
|
- - ! '>='
|
123
121
|
- !ruby/object:Gem::Version
|
124
122
|
version: '0'
|
125
|
-
segments:
|
126
|
-
- 0
|
127
|
-
hash: -201331315228927799
|
128
123
|
requirements: []
|
129
124
|
rubyforge_project:
|
130
125
|
rubygems_version: 1.8.23
|
@@ -158,6 +153,7 @@ test_files:
|
|
158
153
|
- spec/fixtures/web_hooks.yaml
|
159
154
|
- spec/fixtures/yank
|
160
155
|
- spec/gems/client_spec.rb
|
156
|
+
- spec/gems/request_spec.rb
|
161
157
|
- spec/gems_spec.rb
|
162
158
|
- spec/helper.rb
|
163
159
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|