routemaster-drain 2.5.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8a5640a28912f9a420499c2b78e69419ac6c407
4
- data.tar.gz: 9391680b0214de9146ca8572f31500c59a70f54e
3
+ metadata.gz: b0feb14006a0d3933006b02516a4c8a4676b338b
4
+ data.tar.gz: c347cbb8284e81d53f857989a620c17eecf938e7
5
5
  SHA512:
6
- metadata.gz: 3ab107f957533a24219671a2191bc12356ef26484daf63dd184e1f6c8c4c40901680743801d64a5b1830259ae6dd1a84370e0732719789a779307c5ebdabfd05
7
- data.tar.gz: ae7fe0e757d08b692ed15f6ee3c2bdcab205b782f472d079af720672b9fdd482afc030bd09355dff9e07b652579b668c584e0845314ea6b74e4e934678829a51
6
+ metadata.gz: fc38c577ba8973327205789530b3195e6a4b5a012e9a6486b9fc1bcdfa9f6ff7ed94a6e8c10d83fed398b3b9d32351937ea0fd9cf5750e8cfdd51106e733c5d3
7
+ data.tar.gz: f5f64de478a53d3462b6d869b9771c6c8dcf8bea0013fbfeb6de70f3095fad40434840c67e8c3fc01a1bc0ca5003b6160a9415eaf31bab5567b4ace00a66b983
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### 3.0.0 (2017-06-22)
2
+
3
+ Breaking API changes
4
+
5
+ - Removes the `#with_response` API client method. (#54)
6
+
7
+ Bug fixes
8
+
9
+ - Remove state from api client for thread safety. (#54)
10
+
11
+
1
12
  ### 2.5.4 (2017-06-12)
2
13
 
3
14
  Bug fixes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-drain (2.5.4)
4
+ routemaster-drain (3.0.0)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.4)
4
+ routemaster-drain (3.0.0)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.4)
4
+ routemaster-drain (3.0.0)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.4)
4
+ routemaster-drain (3.0.0)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -40,11 +40,11 @@ module Routemaster
40
40
  metrics_client: nil,
41
41
  source_peer: nil)
42
42
 
43
- @listener = listener
44
- @middlewares = middlewares
45
- @response_class = response_class
46
- @metrics_client = metrics_client
47
- @source_peer = source_peer
43
+ @listener = listener
44
+ @middlewares = middlewares
45
+ @default_response_class = response_class
46
+ @metrics_client = metrics_client
47
+ @source_peer = source_peer
48
48
 
49
49
  connection # warm up connection so Faraday does all it's magical file loading in the main thread
50
50
  end
@@ -57,12 +57,14 @@ module Routemaster
57
57
  # string otherwise.
58
58
  def get(url, params: {}, headers: {}, options: {})
59
59
  enable_caching = options.fetch(:enable_caching, true)
60
+ response_class = options[:response_class]
60
61
 
61
62
  _wrapped_response _request(
62
63
  :get,
63
64
  url: url,
64
65
  params: params,
65
- headers: headers.merge(response_cache_opt_headers(enable_caching)))
66
+ headers: headers.merge(response_cache_opt_headers(enable_caching))),
67
+ response_class: response_class
66
68
  end
67
69
 
68
70
  # Same as {{get}}, except with
@@ -95,14 +97,6 @@ module Routemaster
95
97
  @@root_resources[url] ||= get(url)
96
98
  end
97
99
 
98
- def with_response(response_class)
99
- memo = @response_class
100
- @response_class = response_class
101
- yield self
102
- ensure
103
- @response_class = memo
104
- end
105
-
106
100
  private
107
101
 
108
102
  def _assert_uri(url)
@@ -121,8 +115,9 @@ module Routemaster
121
115
  end
122
116
  end
123
117
 
124
- def _wrapped_response(response)
125
- @response_class ? @response_class.new(response, client: self) : response
118
+ def _wrapped_response(response, response_class: nil)
119
+ response_class = response_class || @default_response_class
120
+ response_class ? response_class.new(response, client: self) : response
126
121
  end
127
122
 
128
123
  def connection
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '2.5.4'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
@@ -13,27 +13,24 @@ module Routemaster
13
13
  end
14
14
 
15
15
  def create(params)
16
- @client.with_response(Responses::HateoasResponse) do
17
- @client.post(expanded_url, body: params)
18
- end
16
+ @client.post(expanded_url, body: params)
19
17
  end
20
18
 
21
19
  def show(id=nil, enable_caching: true)
22
- @client.with_response(Responses::HateoasResponse) do
23
- @client.get(expanded_url(id: id), options: { enable_caching: enable_caching })
24
- end
20
+ @client.get(expanded_url(id: id), options: { enable_caching: enable_caching })
25
21
  end
26
22
 
27
23
  def index(params: {}, filters: {}, enable_caching: false)
28
- @client.with_response(Responses::HateoasEnumerableResponse) do
29
- @client.get(expanded_url, params: params.merge(filters), options: { enable_caching: enable_caching })
30
- end
24
+ @client.get(
25
+ expanded_url, params: params.merge(filters), options: {
26
+ enable_caching: enable_caching,
27
+ response_class: Responses::HateoasEnumerableResponse
28
+ }
29
+ )
31
30
  end
32
31
 
33
32
  def update(id=nil, params)
34
- @client.with_response(Responses::HateoasResponse) do
35
- @client.patch(expanded_url(id: id), body: params)
36
- end
33
+ @client.patch(expanded_url(id: id), body: params)
37
34
  end
38
35
 
39
36
  def destroy(id=nil)
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Julien Letessier']
10
10
  spec.email = ['julien.letessier@gmail.com']
11
11
  spec.summary = %q{Event receiver for the Routemaster bus}
12
- spec.homepage = 'http://github.com/HouseTrip/routemaster_drain'
12
+ spec.homepage = 'http://github.com/deliveroo/routemaster-drain'
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
@@ -210,32 +210,4 @@ describe Routemaster::APIClient do
210
210
  expect(@req).to have_been_requested
211
211
  end
212
212
  end
213
-
214
- describe '#with_response' do
215
- before { stub_request(:any, //).to_return(status: 200) }
216
-
217
- class DummyResponseA
218
- def initialize(res, client: nil); end
219
- def dummy_a; true; end
220
- end
221
-
222
- class DummyResponseB
223
- def initialize(res, client: nil); end
224
- def dummy_b; true; end
225
- end
226
-
227
- subject { described_class.new(response_class: DummyResponseA) }
228
- let(:response) { subject.get('https://example.com') }
229
-
230
- it 'changes the response wrapper during the block' do
231
- subject.with_response(DummyResponseB) do
232
- expect(response).to respond_to(:dummy_b)
233
- end
234
- end
235
-
236
- it 'restores the original response wrapper after the block' do
237
- subject.with_response(DummyResponseB) {}
238
- expect(response).to respond_to(:dummy_a)
239
- end
240
- end
241
213
  end
@@ -7,8 +7,6 @@ module Routemaster
7
7
  let(:client) { double('Client') }
8
8
  let(:params) { {} }
9
9
 
10
- before { allow(client).to receive(:with_response).and_yield }
11
-
12
10
  describe "singular resource" do
13
11
  let(:url) { '/resources/1' }
14
12
 
@@ -50,7 +48,11 @@ module Routemaster
50
48
 
51
49
  describe '#index' do
52
50
  it 'gets to the given url' do
53
- expect(client).to receive(:get).with(url, params: {}, options: { enable_caching: false })
51
+ expect(client).to receive(:get).with(
52
+ url, params: {}, options: {
53
+ enable_caching: false, response_class: Routemaster::Responses::HateoasEnumerableResponse
54
+ }
55
+ )
54
56
  subject.index
55
57
  end
56
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routemaster-drain
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-12 00:00:00.000000000 Z
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -248,7 +248,7 @@ files:
248
248
  - spec/support/uses_dotenv.rb
249
249
  - spec/support/uses_redis.rb
250
250
  - spec/support/uses_webmock.rb
251
- homepage: http://github.com/HouseTrip/routemaster_drain
251
+ homepage: http://github.com/deliveroo/routemaster-drain
252
252
  licenses:
253
253
  - MIT
254
254
  metadata: {}
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: '0'
269
269
  requirements: []
270
270
  rubyforge_project:
271
- rubygems_version: 2.6.8
271
+ rubygems_version: 2.6.11
272
272
  signing_key:
273
273
  specification_version: 4
274
274
  summary: Event receiver for the Routemaster bus