gh 0.15.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/gh.rb +1 -1
- data/lib/gh/merge_commit.rb +3 -3
- data/lib/gh/normalizer.rb +1 -1
- data/lib/gh/remote.rb +8 -4
- data/lib/gh/response_x_header_formatter.rb +12 -0
- data/lib/gh/token_check.rb +1 -1
- data/lib/gh/version.rb +1 -1
- metadata +46 -50
- data/lib/gh/faraday_adapter.rb +0 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16d87ecc5b3c30bf97a8a4bb031f92f5f0f6158f
|
4
|
+
data.tar.gz: 1faf61eced641abc7cc16f078713406ddac90a8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d950b13a2578b2d3224501075e7a4700464e207919d7d2f208cc54ce4eb16bb5216daae061d3834d6e79cc1295a7753b16d1ab3766b231b8eb779de014a1a33
|
7
|
+
data.tar.gz: bd2f9066b1f1be9060d10a9a246d60959d4e6f7e2597a3652594c6155db8fb9b72aa8ef553fd4287c33634bed4b08ad51da1f725ea71fe8c45ad75531cb3bfef
|
data/lib/gh.rb
CHANGED
@@ -7,7 +7,6 @@ module GH
|
|
7
7
|
autoload :Case, 'gh/case'
|
8
8
|
autoload :CustomLimit, 'gh/custom_limit'
|
9
9
|
autoload :Error, 'gh/error'
|
10
|
-
autoload :FaradayAdapter, 'gh/faraday_adapter'
|
11
10
|
autoload :Instrumentation, 'gh/instrumentation'
|
12
11
|
autoload :LazyLoader, 'gh/lazy_loader'
|
13
12
|
autoload :LinkFollower, 'gh/link_follower'
|
@@ -17,6 +16,7 @@ module GH
|
|
17
16
|
autoload :Parallel, 'gh/parallel'
|
18
17
|
autoload :Remote, 'gh/remote'
|
19
18
|
autoload :Response, 'gh/response'
|
19
|
+
autoload :ResponseXHeaderFormatter, 'gh/response_x_header_formatter'
|
20
20
|
autoload :ResponseWrapper, 'gh/response_wrapper'
|
21
21
|
autoload :Stack, 'gh/stack'
|
22
22
|
autoload :TokenCheck, 'gh/token_check'
|
data/lib/gh/merge_commit.rb
CHANGED
@@ -58,9 +58,9 @@ module GH
|
|
58
58
|
|
59
59
|
def github_done_checking?(hash)
|
60
60
|
case hash['mergeable_state']
|
61
|
-
when 'checking'
|
62
|
-
when 'unknown'
|
63
|
-
when 'clean', 'dirty', 'unstable', 'stable'
|
61
|
+
when 'checking' then false
|
62
|
+
when 'unknown' then hash['merged']
|
63
|
+
when 'clean', 'dirty', 'unstable', 'stable', 'blocked', 'behind', 'draft' then true
|
64
64
|
else fail "unknown mergeable_state #{hash['mergeable_state'].inspect} for #{url(hash)}"
|
65
65
|
end
|
66
66
|
end
|
data/lib/gh/normalizer.rb
CHANGED
@@ -99,7 +99,7 @@ module GH
|
|
99
99
|
when /^repos?_(.*)$/ then "repository_#{$1}"
|
100
100
|
when /^(.*)_repo$/ then "#{$1}_repository"
|
101
101
|
when /^(.*)_repos$/ then "#{$1}_repositories"
|
102
|
-
when 'commit', 'commit_id', 'id' then value =~ /^\w{40}$/ ? 'sha' : key
|
102
|
+
when 'commit', 'commit_id', 'id' then value.to_s =~ /^\w{40}$/ ? 'sha' : key
|
103
103
|
when 'comments' then Numeric === value ? 'comment_count' : key
|
104
104
|
when 'forks' then Numeric === value ? 'fork_count' : key
|
105
105
|
when 'repositories' then Numeric === value ? 'repository_count' : key
|
data/lib/gh/remote.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'gh'
|
2
2
|
require 'faraday'
|
3
|
+
require 'active_support/core_ext/string'
|
3
4
|
|
4
5
|
module GH
|
5
6
|
# Public: This class deals with HTTP requests to Github. It is the base Wrapper you always want to use.
|
@@ -7,7 +8,7 @@ module GH
|
|
7
8
|
class Remote < Wrapper
|
8
9
|
attr_reader :api_host, :connection, :headers, :prefix
|
9
10
|
|
10
|
-
# Public: Generates a new
|
11
|
+
# Public: Generates a new Remote instance.
|
11
12
|
#
|
12
13
|
# api_host - HTTP host to send requests to, has to include schema (https or http)
|
13
14
|
# options - Hash with configuration options:
|
@@ -16,7 +17,6 @@ module GH
|
|
16
17
|
# :password - Github password used for login (optional).
|
17
18
|
# :origin - Value of the origin request header (optional).
|
18
19
|
# :headers - HTTP headers to be send on every request (optional).
|
19
|
-
# :adapter - HTTP library to use for making requests (optional, default: :net_http)
|
20
20
|
#
|
21
21
|
# It is highly recommended to set origin, but not to set headers.
|
22
22
|
# If you set the username, you should also set the password.
|
@@ -48,7 +48,10 @@ module GH
|
|
48
48
|
builder.request(:basic_auth, username, password) if username and password
|
49
49
|
builder.request(:retry)
|
50
50
|
builder.response(:raise_error)
|
51
|
-
|
51
|
+
if defined? FaradayMiddleware::Instrumentation
|
52
|
+
builder.use :instrumentation
|
53
|
+
end
|
54
|
+
builder.response(:logger, nil, formatter: GH.const_get(options[:formatter].camelize)) if options[:formatter]
|
52
55
|
builder.adapter(:net_http)
|
53
56
|
end
|
54
57
|
end
|
@@ -74,7 +77,8 @@ module GH
|
|
74
77
|
|
75
78
|
# Internal: ...
|
76
79
|
def http(verb, url, headers = {}, &block)
|
77
|
-
|
80
|
+
body = headers.delete :body
|
81
|
+
connection.run_request(verb, url, body, headers, &block)
|
78
82
|
rescue Exception => error
|
79
83
|
raise Error.new(error, nil, :verb => verb, :url => url, :headers => headers)
|
80
84
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'faraday/logging/formatter'
|
2
|
+
|
3
|
+
module GH
|
4
|
+
class ResponseXHeaderFormatter < Faraday::Logging::Formatter
|
5
|
+
def request(env)
|
6
|
+
end
|
7
|
+
|
8
|
+
def response(env)
|
9
|
+
info('Response') { env.response_headers.select {|k,v| k =~ /^x-/}.sort.to_h }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/gh/token_check.rb
CHANGED
@@ -18,7 +18,7 @@ module GH
|
|
18
18
|
@check_token = false
|
19
19
|
|
20
20
|
auth_header = "Basic %s" % Base64.encode64("#{client_id}:#{client_secret}").gsub("\n", "")
|
21
|
-
http :
|
21
|
+
http :post, path_for("/applications/#{client_id}/token"), :body => "{\"access_token\": \"#{token}\"}", "Authorization" => auth_header
|
22
22
|
rescue GH::Error(:response_status => 404) => error
|
23
23
|
raise GH::TokenInvalid, error
|
24
24
|
end
|
data/lib/gh/version.rb
CHANGED
metadata
CHANGED
@@ -1,142 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.18.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Konstantin Haase
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-06-25 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
|
53
|
-
version: '0
|
47
|
+
version: '1.0'
|
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
|
61
|
-
version: '0
|
54
|
+
version: '1.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
56
|
+
name: faraday_middleware
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
61
|
+
version: '1.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
|
-
version: '0'
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
84
|
name: multi_json
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
|
-
- - ~>
|
87
|
+
- - "~>"
|
84
88
|
- !ruby/object:Gem::Version
|
85
89
|
version: '1.0'
|
86
90
|
type: :runtime
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- - ~>
|
94
|
+
- - "~>"
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '1.0'
|
94
97
|
- !ruby/object:Gem::Dependency
|
95
98
|
name: addressable
|
96
99
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
100
|
requirements:
|
99
|
-
- - ~>
|
101
|
+
- - "~>"
|
100
102
|
- !ruby/object:Gem::Version
|
101
|
-
version: 2.4
|
103
|
+
version: '2.4'
|
102
104
|
type: :runtime
|
103
105
|
prerelease: false
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
107
|
requirements:
|
107
|
-
- - ~>
|
108
|
+
- - "~>"
|
108
109
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.4
|
110
|
+
version: '2.4'
|
110
111
|
- !ruby/object:Gem::Dependency
|
111
112
|
name: net-http-persistent
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '2.9'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
121
|
requirements:
|
123
|
-
- - ~>
|
122
|
+
- - "~>"
|
124
123
|
- !ruby/object:Gem::Version
|
125
124
|
version: '2.9'
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
126
|
name: net-http-pipeline
|
128
127
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
128
|
requirements:
|
131
|
-
- -
|
129
|
+
- - ">="
|
132
130
|
- !ruby/object:Gem::Version
|
133
131
|
version: '0'
|
134
132
|
type: :runtime
|
135
133
|
prerelease: false
|
136
134
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
135
|
requirements:
|
139
|
-
- -
|
136
|
+
- - ">="
|
140
137
|
- !ruby/object:Gem::Version
|
141
138
|
version: '0'
|
142
139
|
description: multi-layer client for the github api v3
|
@@ -152,7 +149,6 @@ files:
|
|
152
149
|
- lib/gh/case.rb
|
153
150
|
- lib/gh/custom_limit.rb
|
154
151
|
- lib/gh/error.rb
|
155
|
-
- lib/gh/faraday_adapter.rb
|
156
152
|
- lib/gh/instrumentation.rb
|
157
153
|
- lib/gh/lazy_loader.rb
|
158
154
|
- lib/gh/link_follower.rb
|
@@ -164,6 +160,7 @@ files:
|
|
164
160
|
- lib/gh/remote.rb
|
165
161
|
- lib/gh/response.rb
|
166
162
|
- lib/gh/response_wrapper.rb
|
163
|
+
- lib/gh/response_x_header_formatter.rb
|
167
164
|
- lib/gh/stack.rb
|
168
165
|
- lib/gh/token_check.rb
|
169
166
|
- lib/gh/version.rb
|
@@ -171,26 +168,25 @@ files:
|
|
171
168
|
homepage: https://github.com/travis-ci/gh
|
172
169
|
licenses:
|
173
170
|
- MIT
|
171
|
+
metadata: {}
|
174
172
|
post_install_message:
|
175
173
|
rdoc_options: []
|
176
174
|
require_paths:
|
177
175
|
- lib
|
178
176
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
-
none: false
|
180
177
|
requirements:
|
181
|
-
- -
|
178
|
+
- - ">="
|
182
179
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
180
|
+
version: 2.3.0
|
184
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
182
|
requirements:
|
187
|
-
- -
|
183
|
+
- - ">="
|
188
184
|
- !ruby/object:Gem::Version
|
189
185
|
version: '0'
|
190
186
|
requirements: []
|
191
187
|
rubyforge_project:
|
192
|
-
rubygems_version:
|
188
|
+
rubygems_version: 2.6.14
|
193
189
|
signing_key:
|
194
|
-
specification_version:
|
190
|
+
specification_version: 4
|
195
191
|
summary: layered github client
|
196
192
|
test_files: []
|
data/lib/gh/faraday_adapter.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'gh'
|
2
|
-
require 'faraday'
|
3
|
-
require 'thread'
|
4
|
-
require 'net/https'
|
5
|
-
require 'net/http/pipeline'
|
6
|
-
require 'net/http/persistent'
|
7
|
-
|
8
|
-
module GH
|
9
|
-
# Faraday adapter based on Net::HTTP, with persistent connection and pipeline support.
|
10
|
-
class FaradayAdapter < Faraday::Adapter::NetHttpPersistent
|
11
|
-
class Manager
|
12
|
-
def initialize(*)
|
13
|
-
@mutex = Mutex.new
|
14
|
-
@requests = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_request(http, env, adapter)
|
18
|
-
url = env[:url] + '/'
|
19
|
-
env[:adapter] = adapter
|
20
|
-
|
21
|
-
@mutex.synchronize do
|
22
|
-
@requests[url] ||= []
|
23
|
-
@requests[url] << env
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def run
|
28
|
-
requests = nil
|
29
|
-
@mutex.synchronize { requests, @requests = @requests, {} }
|
30
|
-
http = Net::HTTP::Persistent.new 'GH'
|
31
|
-
requests.each do |url, envs|
|
32
|
-
_requests = envs.map { |env| env[:adapter].create_request(env) }
|
33
|
-
responses = http.pipeline(url, _requests)
|
34
|
-
envs.zip(responses) do |env, http_response|
|
35
|
-
env[:adapter].save_response(env, http_response.code.to_i, http_response.body) do |headers|
|
36
|
-
http_response.each_header { |key, value| headers[key] = value }
|
37
|
-
end
|
38
|
-
env[:response].finish(env)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
self.supports_parallel = true
|
45
|
-
|
46
|
-
def self.setup_parallel_manager(options = {})
|
47
|
-
Manager.new(options)
|
48
|
-
end
|
49
|
-
|
50
|
-
def call(env)
|
51
|
-
catch(:parallel) { super }
|
52
|
-
end
|
53
|
-
|
54
|
-
def perform_request(http, env)
|
55
|
-
return super unless env[:parallel_manager]
|
56
|
-
env[:parallel_manager].add_request(http, env, self)
|
57
|
-
throw :parallel, @app.call(env)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|