routemaster-drain 2.5.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +11 -0
 - data/Gemfile.lock +1 -1
 - data/gemfiles/rails_3.gemfile.lock +1 -1
 - data/gemfiles/rails_4.gemfile.lock +1 -1
 - data/gemfiles/rails_5.gemfile.lock +1 -1
 - data/lib/routemaster/api_client.rb +11 -16
 - data/lib/routemaster/drain.rb +1 -1
 - data/lib/routemaster/resources/rest_resource.rb +9 -12
 - data/routemaster-drain.gemspec +1 -1
 - data/spec/routemaster/api_client_spec.rb +0 -28
 - data/spec/routemaster/resources/rest_resource_spec.rb +5 -3
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b0feb14006a0d3933006b02516a4c8a4676b338b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c347cbb8284e81d53f857989a620c17eecf938e7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fc38c577ba8973327205789530b3195e6a4b5a012e9a6486b9fc1bcdfa9f6ff7ed94a6e8c10d83fed398b3b9d32351937ea0fd9cf5750e8cfdd51106e733c5d3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f5f64de478a53d3462b6d869b9771c6c8dcf8bea0013fbfeb6de70f3095fad40434840c67e8c3fc01a1bc0ca5003b6160a9415eaf31bab5567b4ace00a66b983
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
| 
         @@ -40,11 +40,11 @@ module Routemaster 
     | 
|
| 
       40 
40 
     | 
    
         
             
                               metrics_client: nil,
         
     | 
| 
       41 
41 
     | 
    
         
             
                               source_peer: nil)
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                  @listener 
     | 
| 
       44 
     | 
    
         
            -
                  @middlewares 
     | 
| 
       45 
     | 
    
         
            -
                  @ 
     | 
| 
       46 
     | 
    
         
            -
                  @metrics_client 
     | 
| 
       47 
     | 
    
         
            -
                  @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 
     | 
    
         
            -
                   
     | 
| 
      
 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
         
     | 
    
        data/lib/routemaster/drain.rb
    CHANGED
    
    
| 
         @@ -13,27 +13,24 @@ module Routemaster 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  def create(params)
         
     | 
| 
       16 
     | 
    
         
            -
                    @client. 
     | 
| 
       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. 
     | 
| 
       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. 
     | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 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. 
     | 
| 
       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)
         
     | 
    
        data/routemaster-drain.gemspec
    CHANGED
    
    | 
         @@ -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/ 
     | 
| 
      
 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( 
     | 
| 
      
 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:  
     | 
| 
      
 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- 
     | 
| 
      
 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/ 
     | 
| 
      
 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. 
     | 
| 
      
 271 
     | 
    
         
            +
            rubygems_version: 2.6.11
         
     | 
| 
       272 
272 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       273 
273 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       274 
274 
     | 
    
         
             
            summary: Event receiver for the Routemaster bus
         
     |