gh 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +3 -3
- data/lib/gh/custom_limit.rb +3 -3
- data/lib/gh/normalizer.rb +1 -1
- data/lib/gh/pagination.rb +1 -1
- data/lib/gh/remote.rb +12 -2
- data/lib/gh/token_check.rb +3 -2
- data/lib/gh/version.rb +1 -1
- data/lib/gh/wrapper.rb +6 -10
- data/spec/custom_limit_spec.rb +10 -3
- data/spec/spec_helper.rb +1 -1
- metadata +19 -37
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43020016e261c85569cfa40a4a92753523a42a13
|
4
|
+
data.tar.gz: 5eacd265750783b05a3f14ec64e666252cf81526
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0722d2c77d6bda9093fb7c1b96197413798abfdacf2ac5b3bdacfea552d1b05ab1ab0b9a4a191c2c788728bad9de12b0c75b043587846eba3aba1efa1ec04ac9
|
7
|
+
data.tar.gz: 657ee818d39385caeb1ca73d75a2db88bad3361783e8e2ab9a2157ae08f9b4c688be5b94d17442989262a8511e2895d987c686235903548eac7ab77164930904
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gh (0.11.
|
4
|
+
gh (0.11.2)
|
5
5
|
addressable
|
6
6
|
backports
|
7
7
|
faraday (~> 0.8)
|
@@ -13,12 +13,12 @@ GEM
|
|
13
13
|
remote: http://rubygems.org/
|
14
14
|
specs:
|
15
15
|
addressable (2.3.4)
|
16
|
-
backports (3.3.
|
16
|
+
backports (3.3.3)
|
17
17
|
crack (0.3.2)
|
18
18
|
diff-lcs (1.2.4)
|
19
19
|
faraday (0.8.7)
|
20
20
|
multipart-post (~> 1.1)
|
21
|
-
multi_json (1.7.
|
21
|
+
multi_json (1.7.7)
|
22
22
|
multipart-post (1.2.0)
|
23
23
|
net-http-persistent (2.8)
|
24
24
|
net-http-pipeline (1.0.1)
|
data/lib/gh/custom_limit.rb
CHANGED
@@ -9,10 +9,10 @@ module GH
|
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def full_url(key)
|
13
13
|
return super unless client_id
|
14
14
|
|
15
|
-
url =
|
15
|
+
url = super
|
16
16
|
params = url.query_values || {}
|
17
17
|
|
18
18
|
unless params.include? 'client_id'
|
@@ -21,7 +21,7 @@ module GH
|
|
21
21
|
end
|
22
22
|
|
23
23
|
url.query_values = params
|
24
|
-
|
24
|
+
url
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/gh/normalizer.rb
CHANGED
@@ -6,7 +6,7 @@ module GH
|
|
6
6
|
class Normalizer < Wrapper
|
7
7
|
def generate_response(key, response)
|
8
8
|
result = super
|
9
|
-
links(result)['self'] ||= { 'href' => full_url(key).to_s } if result.respond_to? :to_hash
|
9
|
+
links(result)['self'] ||= { 'href' => frontend.full_url(key).to_s } if result.respond_to? :to_hash
|
10
10
|
result
|
11
11
|
end
|
12
12
|
|
data/lib/gh/pagination.rb
CHANGED
data/lib/gh/remote.rb
CHANGED
@@ -61,14 +61,14 @@ module GH
|
|
61
61
|
|
62
62
|
# Internal: ...
|
63
63
|
def fetch_resource(key)
|
64
|
-
frontend.http(:get, path_for(key), headers)
|
64
|
+
frontend.http(:get, frontend.path_for(key), headers)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Internal: ...
|
68
68
|
def generate_response(key, response)
|
69
69
|
body, headers = response.body, response.headers
|
70
70
|
url = response.respond_to?(:url) ? response.url : response.env.try(:[], :url)
|
71
|
-
url = full_url(key) if url.to_s.empty?
|
71
|
+
url = frontend.full_url(key) if url.to_s.empty?
|
72
72
|
modify(body, headers, url)
|
73
73
|
end
|
74
74
|
|
@@ -126,6 +126,16 @@ module GH
|
|
126
126
|
raise RuntimeError, "use GH::Parallel middleware for #in_parallel support"
|
127
127
|
end
|
128
128
|
|
129
|
+
def full_url(key)
|
130
|
+
uri = api_host + Addressable::URI.parse(key)
|
131
|
+
raise ArgumentError, "URI out of scope: #{key}" if uri.host != api_host.host
|
132
|
+
uri
|
133
|
+
end
|
134
|
+
|
135
|
+
def path_for(key)
|
136
|
+
frontend.full_url(key).request_uri
|
137
|
+
end
|
138
|
+
|
129
139
|
private
|
130
140
|
|
131
141
|
def identifier(key)
|
data/lib/gh/token_check.rb
CHANGED
@@ -15,14 +15,15 @@ module GH
|
|
15
15
|
|
16
16
|
def check_token
|
17
17
|
return unless @check_token and client_id and client_secret and token
|
18
|
+
@check_token = false
|
19
|
+
|
18
20
|
auth_header = "Basic %s" % Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", "")
|
19
21
|
http :head, "/applications/#{client_id}/tokens/#{token}?client_id=#{client_id}&client_secret=#{client_secret}", "Authorization" => auth_header
|
20
|
-
@check_token = false
|
21
22
|
rescue GH::Error(:response_status => 404) => error
|
22
23
|
raise GH::TokenInvalid, error
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
+
def http(*)
|
26
27
|
check_token
|
27
28
|
super
|
28
29
|
end
|
data/lib/gh/version.rb
CHANGED
data/lib/gh/wrapper.rb
CHANGED
@@ -63,6 +63,12 @@ module GH
|
|
63
63
|
# Public: ...
|
64
64
|
def_delegator :backend, :in_parallel?
|
65
65
|
|
66
|
+
# Public: ...
|
67
|
+
def_delegator :backend, :full_url
|
68
|
+
|
69
|
+
# Public: ...
|
70
|
+
def_delegator :backend, :path_for
|
71
|
+
|
66
72
|
# Public: Retrieves resources from Github.
|
67
73
|
def self.[](key)
|
68
74
|
new[key]
|
@@ -198,12 +204,6 @@ module GH
|
|
198
204
|
[backend, options]
|
199
205
|
end
|
200
206
|
|
201
|
-
def full_url(key)
|
202
|
-
uri = api_host + Addressable::URI.parse(key)
|
203
|
-
raise ArgumentError, "URI out of scope: #{key}" if uri.host != api_host.host
|
204
|
-
uri
|
205
|
-
end
|
206
|
-
|
207
207
|
def setup_default_proc(hash, &block)
|
208
208
|
old_proc = hash.default_proc
|
209
209
|
hash.default_proc = proc do |hash, key|
|
@@ -227,9 +227,5 @@ module GH
|
|
227
227
|
end
|
228
228
|
hash
|
229
229
|
end
|
230
|
-
|
231
|
-
def path_for(key)
|
232
|
-
full_url(key).request_uri
|
233
|
-
end
|
234
230
|
end
|
235
231
|
end
|
data/spec/custom_limit_spec.rb
CHANGED
@@ -7,10 +7,17 @@ describe GH::CustomLimit do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'adds client_id and client_secret to a request' do
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
headers = {
|
11
|
+
"User-Agent" => "GH/0.11.2",
|
12
|
+
"Accept" => "application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1",
|
13
|
+
"Accept-Charset" => "utf-8"
|
14
|
+
}
|
15
|
+
|
16
|
+
subject.
|
17
|
+
should_receive(:http).
|
18
|
+
with(:get, '/x?client_id=foo&client_secret=bar', headers).
|
13
19
|
and_return(GH::Response.new)
|
20
|
+
|
14
21
|
subject['/x']
|
15
22
|
end
|
16
23
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,52 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
5
|
-
prerelease:
|
4
|
+
version: 0.11.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Konstantin Haase
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-05
|
11
|
+
date: 2013-07-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: webmock
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: faraday
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,23 +55,20 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: backports
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: multi_json
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,49 +83,43 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: addressable
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: net-http-persistent
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '2.7'
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '2.7'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: net-http-pipeline
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
description: multi-layer client for the github api v3
|
@@ -217,27 +200,26 @@ files:
|
|
217
200
|
- spec/wrapper_spec.rb
|
218
201
|
homepage: http://gh.rkh.im/
|
219
202
|
licenses: []
|
203
|
+
metadata: {}
|
220
204
|
post_install_message:
|
221
205
|
rdoc_options: []
|
222
206
|
require_paths:
|
223
207
|
- lib
|
224
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
-
none: false
|
226
209
|
requirements:
|
227
|
-
- -
|
210
|
+
- - '>='
|
228
211
|
- !ruby/object:Gem::Version
|
229
212
|
version: '0'
|
230
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
|
-
none: false
|
232
214
|
requirements:
|
233
|
-
- -
|
215
|
+
- - '>='
|
234
216
|
- !ruby/object:Gem::Version
|
235
217
|
version: '0'
|
236
218
|
requirements: []
|
237
219
|
rubyforge_project:
|
238
|
-
rubygems_version:
|
220
|
+
rubygems_version: 2.0.2
|
239
221
|
signing_key:
|
240
|
-
specification_version:
|
222
|
+
specification_version: 4
|
241
223
|
summary: layered github client
|
242
224
|
test_files:
|
243
225
|
- spec/cache_spec.rb
|