gh 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -5
- data/gh.gemspec +2 -1
- data/lib/gh.rb +7 -2
- data/lib/gh/error.rb +17 -0
- data/lib/gh/instrumentation.rb +36 -0
- data/lib/gh/lazy_loader.rb +4 -0
- data/lib/gh/link_follower.rb +4 -0
- data/lib/gh/merge_commit.rb +38 -12
- data/lib/gh/normalizer.rb +2 -0
- data/lib/gh/pagination.rb +31 -0
- data/lib/gh/remote.rb +27 -7
- data/lib/gh/response.rb +6 -0
- data/lib/gh/version.rb +1 -1
- data/lib/gh/wrapper.rb +14 -0
- data/spec/error_spec.rb +31 -0
- data/spec/instrumentation_spec.rb +30 -0
- data/spec/merge_commit_spec.rb +12 -0
- data/spec/normalizer_spec.rb +5 -0
- data/spec/pagination_spec.rb +10 -0
- data/spec/payloads/.yml +3 -0
- data/spec/payloads/repos/travis-repos/test-project-1/git/commits/ca3c0a44ec1d9bf8557d2653aa1b79fcc9ff5f5d.yml +23 -0
- data/spec/payloads/users/rkh/repos.yml +52 -0
- data/spec/payloads/users/rkh/repos?page=2.yml +54 -0
- data/spec/payloads/users/rkh/repos?page=3.yml +57 -0
- data/spec/payloads/users/rkh/repos?page=4.yml +56 -0
- data/spec/payloads/users/rkh/repos?page=5.yml +28 -0
- data/spec/remote_spec.rb +6 -0
- metadata +46 -14
- data/lib/gh/faraday.rb +0 -99
data/lib/gh/faraday.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009 rick olson, zack hobson
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
-
# this software and associated documentation files (the "Software"), to deal in
|
5
|
-
# the Software without restriction, including without limitation the rights to
|
6
|
-
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
-
# of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
-
# so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in all
|
11
|
-
# copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
|
21
|
-
require 'faraday'
|
22
|
-
|
23
|
-
if Faraday::VERSION < '0.8.0'
|
24
|
-
$stderr.puts "please update faraday"
|
25
|
-
|
26
|
-
# https://github.com/technoweenie/faraday/blob/master/lib/faraday/request/basic_authentication.rb
|
27
|
-
require 'base64'
|
28
|
-
|
29
|
-
module Faraday
|
30
|
-
class Request::BasicAuthentication < Faraday::Middleware
|
31
|
-
def initialize(app, login, pass)
|
32
|
-
super(app)
|
33
|
-
@header_value = "Basic #{Base64.encode64([login, pass].join(':')).gsub("\n", '')}"
|
34
|
-
end
|
35
|
-
|
36
|
-
def call(env)
|
37
|
-
unless env[:request_headers]['Authorization']
|
38
|
-
env[:request_headers]['Authorization'] = @header_value
|
39
|
-
end
|
40
|
-
@app.call(env)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# https://github.com/technoweenie/faraday/blob/master/lib/faraday/request/retry.rb
|
46
|
-
module Faraday
|
47
|
-
class Request::Retry < Faraday::Middleware
|
48
|
-
def initialize(app, retries = 2)
|
49
|
-
@retries = retries
|
50
|
-
super(app)
|
51
|
-
end
|
52
|
-
|
53
|
-
def call(env)
|
54
|
-
retries = @retries
|
55
|
-
begin
|
56
|
-
@app.call(env)
|
57
|
-
rescue StandardError, Timeout::Error
|
58
|
-
if retries > 0
|
59
|
-
retries -= 1
|
60
|
-
retry
|
61
|
-
end
|
62
|
-
raise
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# https://github.com/technoweenie/faraday/blob/master/lib/faraday/request/token_authentication.rb
|
69
|
-
module Faraday
|
70
|
-
class Request::TokenAuthentication < Faraday::Middleware
|
71
|
-
def initialize(app, token, options={})
|
72
|
-
super(app)
|
73
|
-
|
74
|
-
# values = ["token=#{token.to_s.inspect}"]
|
75
|
-
# options.each do |key, value|
|
76
|
-
# values << "#{key}=#{value.to_s.inspect}"
|
77
|
-
# end
|
78
|
-
# comma = ",\n#{' ' * ('Authorization: Token '.size)}"
|
79
|
-
# @header_value = "Token #{values * comma}"
|
80
|
-
@header_value = "token #{token}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def call(env)
|
84
|
-
unless env[:request_headers]['Authorization']
|
85
|
-
env[:request_headers]['Authorization'] = @header_value
|
86
|
-
end
|
87
|
-
@app.call(env)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# https://github.com/technoweenie/faraday/blob/master/lib/faraday/request.rb
|
93
|
-
Faraday::Request.register_lookup_modules \
|
94
|
-
:url_encoded => :UrlEncoded,
|
95
|
-
:multipart => :Multipart,
|
96
|
-
:retry => :Retry,
|
97
|
-
:basic_auth => :BasicAuthentication,
|
98
|
-
:token_auth => :TokenAuthentication
|
99
|
-
end
|