gh 0.7.1 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,10 +29,13 @@ module GH
29
29
  @mutex.synchronize { requests, @requests = @requests, {} }
30
30
  http = Net::HTTP::Persistent.new 'GH'
31
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 |e,r|
35
- e[:adapter].save_response(e, r.code.to_i, r.body) { |h| r.each_header { |k,v| h[k] = v } }
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)
36
39
  end
37
40
  end
38
41
  end
@@ -57,9 +57,18 @@ module GH
57
57
  # until then, please look the other way
58
58
  while hash['mergeable'].nil?
59
59
  url = hash['_links']['html']['href'] + '/mergeable'
60
- case frontend.http(:get, url).body
61
- when "true" then hash['mergeable'] = true
62
- when "false" then hash['mergeable'] = false
60
+ payload = frontend.http(:get, url).body
61
+
62
+ case payload
63
+ when "true", /clean/
64
+ hash['mergeable'] = true
65
+ when "", "null", /checking/
66
+ hash['mergeable'] = nil
67
+ sleep 0.1
68
+ when /unknown/, /dirty/
69
+ hash['mergeable'] = false
70
+ else
71
+ fail "Unkown payload from #{url}: #{payload}"
63
72
  end
64
73
  end
65
74
  end
data/lib/gh/pagination.rb CHANGED
@@ -23,6 +23,10 @@ module GH
23
23
  next_page[value - @page.size]
24
24
  end
25
25
 
26
+ def to_ary
27
+ to_a # replace with better implementation (use in_parallel)
28
+ end
29
+
26
30
  private
27
31
 
28
32
  def next_page
data/lib/gh/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.7.1"
3
+ VERSION = "0.7.3"
4
4
  end
@@ -8,7 +8,7 @@ describe GH::MergeCommit do
8
8
 
9
9
  before do
10
10
  stub_request(:get, "https://github.com/travis-repos/test-project-1/pull/1/mergeable").
11
- to_return(:status => 200, :body => "true", :headers => {})
11
+ to_return(:status => 200, :body => '{"state":"clean"}', :headers => {})
12
12
  end
13
13
 
14
14
  it 'adds merge commits' do
@@ -68,7 +68,26 @@ describe GH::Parallel do
68
68
  end
69
69
  end
70
70
 
71
+ it 'works with pagination' do
72
+ WebMock.allow_net_connect!
73
+ GH::DefaultStack.replace GH::MockBackend, GH::Remote
74
+ repos = GH.in_parallel { GH['users/rkh/repos'] }
75
+ counter = repos.to_a.map { 1 }.reduce(:+)
76
+ counter.should be > 120
77
+ end
78
+
71
79
  it 'returns the block value' do
72
80
  GH.in_parallel { 42 }.should be == 42
73
81
  end
82
+
83
+ it 'works two times in a row' do
84
+ WebMock.allow_net_connect!
85
+ GH::DefaultStack.replace GH::MockBackend, GH::Remote
86
+
87
+ a = GH.in_parallel { GH['users/rkh'] }
88
+ b = GH.in_parallel { GH['users/svenfuchs'] }
89
+
90
+ a['name'].should be == "Konstantin Haase"
91
+ b['name'].should be == "Sven Fuchs"
92
+ end
74
93
  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.7.1
4
+ version: 0.7.3
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-10 00:00:00.000000000 Z
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70105565578080 !ruby/object:Gem::Requirement
16
+ requirement: &70211459176640 !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: *70105565578080
24
+ version_requirements: *70211459176640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: webmock
27
- requirement: &70105565576840 !ruby/object:Gem::Requirement
27
+ requirement: &70211459176060 !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: *70105565576840
35
+ version_requirements: *70211459176060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday
38
- requirement: &70105565576200 !ruby/object:Gem::Requirement
38
+ requirement: &70211459175400 !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: *70105565576200
46
+ version_requirements: *70211459175400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: backports
49
- requirement: &70105565586200 !ruby/object:Gem::Requirement
49
+ requirement: &70211459174700 !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: *70105565586200
57
+ version_requirements: *70211459174700
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70105565583400 !ruby/object:Gem::Requirement
60
+ requirement: &70211459174140 !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: *70105565583400
68
+ version_requirements: *70211459174140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: addressable
71
- requirement: &70105565597220 !ruby/object:Gem::Requirement
71
+ requirement: &70211459173620 !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: *70105565597220
79
+ version_requirements: *70211459173620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: net-http-persistent
82
- requirement: &70105565595200 !ruby/object:Gem::Requirement
82
+ requirement: &70211459172920 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '2.7'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70105565595200
90
+ version_requirements: *70211459172920
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: net-http-pipeline
93
- requirement: &70105565593540 !ruby/object:Gem::Requirement
93
+ requirement: &70211459172100 !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: *70105565593540
101
+ version_requirements: *70211459172100
102
102
  description: multi-layer client for the github api v3
103
103
  email:
104
104
  - konstantin.mailinglists@googlemail.com