gh 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/README.md +0 -14
- data/lib/gh/faraday_adapter.rb +10 -4
- data/lib/gh/parallel.rb +3 -2
- data/lib/gh/remote.rb +5 -1
- data/lib/gh/version.rb +1 -1
- data/spec/parallel_spec.rb +4 -0
- data/spec/response_spec.rb +1 -0
- metadata +18 -18
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -111,17 +111,3 @@ Scoping is thread-safe.
|
|
111
111
|
## Is this production ready?
|
112
112
|
|
113
113
|
I hope so, we use it in production for [Travis CI](http://travis-ci.org/). The work on this library has been funded by the [Travis Love Campaign](https://love.travis-ci.org/).
|
114
|
-
|
115
|
-
## History
|
116
|
-
|
117
|
-
* 2012-04-15: 0.3.0 - added API for posting to github, fix merge commit, disable cache by default
|
118
|
-
* 2012-04-13: 0.2.4 - added support for merge commits
|
119
|
-
* 2012-04-12: 0.2.3 - better normalization
|
120
|
-
* 2012-04-10: 0.2.2 - improved link following
|
121
|
-
* 2012-04-10: 0.2.1 - bug fix release
|
122
|
-
* 2012-04-10: 0.2.0 - added link following plus bug fixes (mainly encoding issues)
|
123
|
-
* 2012-04-06: 0.1.2 - bug fix release (issues with cache reloading)
|
124
|
-
* 2012-04-06: 0.1.1 - bug fix release (DSL fixes)
|
125
|
-
* 2012-04-04: 0.1.0 - many bug fixes plus lazy loading
|
126
|
-
* 2012-03-21: 0.0.1 - first public release
|
127
|
-
* 2012-03-05: project started
|
data/lib/gh/faraday_adapter.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'gh'
|
2
2
|
require 'faraday'
|
3
|
+
require 'thread'
|
3
4
|
require 'net/https'
|
4
5
|
require 'net/http/pipeline'
|
5
6
|
require 'net/http/persistent'
|
@@ -9,20 +10,25 @@ module GH
|
|
9
10
|
class FaradayAdapter < Faraday::Adapter::NetHttpPersistent
|
10
11
|
class Manager
|
11
12
|
def initialize(*)
|
13
|
+
@mutex = Mutex.new
|
12
14
|
@requests = {}
|
13
|
-
@connects = {}
|
14
15
|
end
|
15
16
|
|
16
17
|
def add_request(http, env, adapter)
|
17
18
|
url = env[:url] + '/'
|
18
19
|
env[:adapter] = adapter
|
19
|
-
|
20
|
-
@
|
20
|
+
|
21
|
+
@mutex.synchronize do
|
22
|
+
@requests[url] ||= []
|
23
|
+
@requests[url] << env
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def run
|
28
|
+
requests = nil
|
29
|
+
@mutex.synchronize { requests, @requests = @requests, {} }
|
24
30
|
http = Net::HTTP::Persistent.new 'GH'
|
25
|
-
|
31
|
+
requests.each do |url, envs|
|
26
32
|
requests = envs.map { |env| env[:adapter].create_request(env) }
|
27
33
|
responses = http.pipeline(url, requests)
|
28
34
|
envs.zip(responses) do |e,r|
|
data/lib/gh/parallel.rb
CHANGED
@@ -27,10 +27,11 @@ module GH
|
|
27
27
|
dummy
|
28
28
|
end
|
29
29
|
|
30
|
-
def in_parallel
|
30
|
+
def in_parallel
|
31
31
|
return yield if in_parallel?
|
32
32
|
was, @in_parallel = @in_parallel, true
|
33
|
-
result =
|
33
|
+
result = nil
|
34
|
+
connection.in_parallel { result = yield }
|
34
35
|
@mutex.synchronize do
|
35
36
|
@queue.each { |dummy, key, response| dummy.__delegate__ = backend.generate_response(key, response) }
|
36
37
|
@queue.clear
|
data/lib/gh/remote.rb
CHANGED
@@ -42,12 +42,16 @@ module GH
|
|
42
42
|
faraday_options[:ssl] = options[:ssl] if options[:ssl]
|
43
43
|
faraday_options.merge! options[:faraday_options] if options[:faraday_options]
|
44
44
|
|
45
|
+
adapter = options[:adapter]
|
46
|
+
adapter ||= Faraday::Adapter::NetHttp if defined? RUBY_ENGINE and RUBY_ENGINE == 'jruby'
|
47
|
+
adapter ||= GH::FaradayAdapter
|
48
|
+
|
45
49
|
@connection = Faraday.new(faraday_options) do |builder|
|
46
50
|
builder.request(:authorization, :token, token) if token
|
47
51
|
builder.request(:basic_auth, username, password) if username and password
|
48
52
|
builder.request(:retry)
|
49
53
|
builder.response(:raise_error)
|
50
|
-
builder.use(
|
54
|
+
builder.use(adapter)
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
data/lib/gh/version.rb
CHANGED
data/spec/parallel_spec.rb
CHANGED
data/spec/response_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70100388987640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70100388987640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: webmock
|
27
|
-
requirement: &
|
27
|
+
requirement: &70100388987220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70100388987220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: faraday
|
38
|
-
requirement: &
|
38
|
+
requirement: &70100388986720 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.8'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70100388986720
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: backports
|
49
|
-
requirement: &
|
49
|
+
requirement: &70100388986220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '2.3'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70100388986220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: multi_json
|
60
|
-
requirement: &
|
60
|
+
requirement: &70100386169740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70100386169740
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: addressable
|
71
|
-
requirement: &
|
71
|
+
requirement: &70100386169360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70100386169360
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: net-http-persistent
|
82
|
-
requirement: &
|
82
|
+
requirement: &70100386168900 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70100386168900
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: net-http-pipeline
|
93
|
-
requirement: &
|
93
|
+
requirement: &70100386168480 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70100386168480
|
102
102
|
description: multi-layer client for the github api v3
|
103
103
|
email:
|
104
104
|
- konstantin.mailinglists@googlemail.com
|