gh 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ require 'gh'
2
+ require 'faraday'
3
+ require 'net/https'
4
+ require 'net/http/pipeline'
5
+ require 'net/http/persistent'
6
+
7
+ module GH
8
+ # Faraday adapter based on Net::HTTP, with persistent connection and pipeline support.
9
+ class FaradayAdapter < Faraday::Adapter::NetHttpPersistent
10
+ class Manager
11
+ def initialize(*)
12
+ @requests = {}
13
+ @connects = {}
14
+ end
15
+
16
+ def add_request(http, env, adapter)
17
+ url = env[:url] + '/'
18
+ env[:adapter] = adapter
19
+ @requests[url] ||= []
20
+ @requests[url] << env
21
+ end
22
+
23
+ def run
24
+ http = Net::HTTP::Persistent.new 'GH'
25
+ @requests.each do |url, envs|
26
+ requests = envs.map { |env| env[:adapter].create_request(env) }
27
+ responses = http.pipeline(url, requests)
28
+ envs.zip(responses) do |e,r|
29
+ e[:adapter].save_response(e, r.code.to_i, r.body) { |h| r.each_header { |k,v| h[k] = v } }
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ self.supports_parallel = true
36
+
37
+ def self.setup_parallel_manager(options = {})
38
+ Manager.new(options)
39
+ end
40
+
41
+ def call(env)
42
+ catch(:parallel) { super }
43
+ end
44
+
45
+ def perform_request(http, env)
46
+ return super unless env[:parallel_manager]
47
+ env[:parallel_manager].add_request(http, env, self)
48
+ throw :parallel, @app.call(env)
49
+ end
50
+ end
51
+ end
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
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.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70198913119860 !ruby/object:Gem::Requirement
16
+ requirement: &70251530412660 !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: *70198913119860
24
+ version_requirements: *70251530412660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: webmock
27
- requirement: &70198913119340 !ruby/object:Gem::Requirement
27
+ requirement: &70251530412200 !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: *70198913119340
35
+ version_requirements: *70251530412200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday
38
- requirement: &70198913118820 !ruby/object:Gem::Requirement
38
+ requirement: &70251530411620 !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: *70198913118820
46
+ version_requirements: *70251530411620
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: backports
49
- requirement: &70198913118060 !ruby/object:Gem::Requirement
49
+ requirement: &70251530410820 !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: *70198913118060
57
+ version_requirements: *70251530410820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70198913117360 !ruby/object:Gem::Requirement
60
+ requirement: &70251530410120 !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: *70198913117360
68
+ version_requirements: *70251530410120
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: addressable
71
- requirement: &70198913116660 !ruby/object:Gem::Requirement
71
+ requirement: &70251530409280 !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: *70198913116660
79
+ version_requirements: *70251530409280
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: net-http-persistent
82
- requirement: &70198913136420 !ruby/object:Gem::Requirement
82
+ requirement: &70251530430800 !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: *70198913136420
90
+ version_requirements: *70251530430800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: net-http-pipeline
93
- requirement: &70198913133840 !ruby/object:Gem::Requirement
93
+ requirement: &70251530428340 !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: *70198913133840
101
+ version_requirements: *70251530428340
102
102
  description: multi-layer client for the github api v3
103
103
  email:
104
104
  - konstantin.mailinglists@googlemail.com
@@ -116,6 +116,7 @@ files:
116
116
  - lib/gh/cache.rb
117
117
  - lib/gh/case.rb
118
118
  - lib/gh/error.rb
119
+ - lib/gh/faraday_adapter.rb
119
120
  - lib/gh/instrumentation.rb
120
121
  - lib/gh/lazy_loader.rb
121
122
  - lib/gh/link_follower.rb