gh 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,5 @@ rvm:
12
12
  - ree
13
13
  matrix:
14
14
  allow_failures:
15
- - rvm: jruby-18mode
16
- - rvm: jruby-19mode
17
15
  - rvm: jruby-head
16
+ - rvm: ruby-head
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
@@ -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
- @requests[url] ||= []
20
- @requests[url] << env
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
- @requests.each do |url, envs|
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|
@@ -27,10 +27,11 @@ module GH
27
27
  dummy
28
28
  end
29
29
 
30
- def in_parallel(&block)
30
+ def in_parallel
31
31
  return yield if in_parallel?
32
32
  was, @in_parallel = @in_parallel, true
33
- result = connection.in_parallel(&block)
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
@@ -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(options[:adapter] || GH::FaradayAdapter)
54
+ builder.use(adapter)
51
55
  end
52
56
  end
53
57
 
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
@@ -43,4 +43,8 @@ describe GH::Parallel do
43
43
 
44
44
  GH.should_not be_in_parallel
45
45
  end
46
+
47
+ it 'returns the block value' do
48
+ GH.in_parallel { 42 }.should be == 42
49
+ end
46
50
  end
@@ -10,6 +10,7 @@ describe GH::Response do
10
10
  end
11
11
 
12
12
  it 'handles broken encodings properly' do
13
+ pending if RUBY_ENGINE == 'jruby' # see https://github.com/flori/json/issues/138
13
14
  GH::Response.new({}, "{\"foo\":\"\xC3\"}")["foo"].should be == "\xC3"
14
15
  end
15
16
  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.6.0
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-05 00:00:00.000000000 Z
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: &70302474334740 !ruby/object:Gem::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: *70302474334740
24
+ version_requirements: *70100388987640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: webmock
27
- requirement: &70302474334320 !ruby/object:Gem::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: *70302474334320
35
+ version_requirements: *70100388987220
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday
38
- requirement: &70302474333820 !ruby/object:Gem::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: *70302474333820
46
+ version_requirements: *70100388986720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: backports
49
- requirement: &70302474333320 !ruby/object:Gem::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: *70302474333320
57
+ version_requirements: *70100388986220
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70302474332860 !ruby/object:Gem::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: *70302474332860
68
+ version_requirements: *70100386169740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: addressable
71
- requirement: &70302474332480 !ruby/object:Gem::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: *70302474332480
79
+ version_requirements: *70100386169360
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: net-http-persistent
82
- requirement: &70302474332020 !ruby/object:Gem::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: *70302474332020
90
+ version_requirements: *70100386168900
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: net-http-pipeline
93
- requirement: &70302474331600 !ruby/object:Gem::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: *70302474331600
101
+ version_requirements: *70100386168480
102
102
  description: multi-layer client for the github api v3
103
103
  email:
104
104
  - konstantin.mailinglists@googlemail.com