restful_resource 2.13.4 → 2.15.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 +10 -0
 - data/lib/restful_resource/base.rb +5 -2
 - data/lib/restful_resource/http_client.rb +5 -1
 - data/lib/restful_resource/version.rb +1 -1
 - data/restful_resource.gemspec +1 -1
 - data/spec/restful_resource/base_spec.rb +29 -24
 - data/spec/restful_resource/http_client_spec.rb +12 -0
 - metadata +7 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7af1361039382e70e477e2092457d8d816ed698a2c1e04395eb970fbfd491fde
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: dc56db8631527d46c3e670e338eb5272881233ae50b528cb4e50faaf8a87de46
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a0532d37adbb89b6f53d98a359c3c54f52a11b26d0c7d1ac7b58b814e1831e8ab9825156d9f61676fff0c5c7afb2ede67dff28689922d8cac2bd5680439ef00a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 357089f436e9d7b984a053f1fcc7642366220033a6e5ffdd6e05a1e37096714eff50130e0a1129b97c1393849392f976437f15311ea50edea31398ff794b3b0b
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
| 
         @@ -12,7 +12,9 @@ module RestfulResource 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  timeout: nil,
         
     | 
| 
       13 
13 
     | 
    
         
             
                  open_timeout: nil,
         
     | 
| 
       14 
14 
     | 
    
         
             
                  faraday_config: nil,
         
     | 
| 
       15 
     | 
    
         
            -
                  faraday_options: {} 
     | 
| 
      
 15 
     | 
    
         
            +
                  faraday_options: {},
         
     | 
| 
      
 16 
     | 
    
         
            +
                  default_headers: {}
         
     | 
| 
      
 17 
     | 
    
         
            +
                )
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
19 
     | 
    
         
             
                  @base_url = URI.parse(base_url)
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
         @@ -25,7 +27,8 @@ module RestfulResource 
     | 
|
| 
       25 
27 
     | 
    
         
             
                                                          open_timeout: open_timeout,
         
     | 
| 
       26 
28 
     | 
    
         
             
                                                          instrumentation: instrumentation,
         
     | 
| 
       27 
29 
     | 
    
         
             
                                                          faraday_config: faraday_config,
         
     | 
| 
       28 
     | 
    
         
            -
                                                          faraday_options: faraday_options
         
     | 
| 
      
 30 
     | 
    
         
            +
                                                          faraday_options: faraday_options,
         
     | 
| 
      
 31 
     | 
    
         
            +
                                                          default_headers: default_headers
         
     | 
| 
       29 
32 
     | 
    
         
             
                                                         )
         
     | 
| 
       30 
33 
     | 
    
         
             
                end
         
     | 
| 
       31 
34 
     | 
    
         | 
| 
         @@ -92,7 +92,9 @@ module RestfulResource 
     | 
|
| 
       92 
92 
     | 
    
         
             
                  timeout: nil,
         
     | 
| 
       93 
93 
     | 
    
         
             
                  open_timeout: nil,
         
     | 
| 
       94 
94 
     | 
    
         
             
                  faraday_config: nil,
         
     | 
| 
       95 
     | 
    
         
            -
                  faraday_options: {} 
     | 
| 
      
 95 
     | 
    
         
            +
                  faraday_options: {},
         
     | 
| 
      
 96 
     | 
    
         
            +
                  default_headers: {}
         
     | 
| 
      
 97 
     | 
    
         
            +
                )
         
     | 
| 
       96 
98 
     | 
    
         
             
                  api_name = instrumentation[:api_name]            ||= 'api'
         
     | 
| 
       97 
99 
     | 
    
         
             
                  instrumentation[:request_instrument_name]        ||= "http.#{api_name}"
         
     | 
| 
       98 
100 
     | 
    
         
             
                  instrumentation[:cache_instrument_name]          ||= "http_cache.#{api_name}"
         
     | 
| 
         @@ -123,6 +125,8 @@ module RestfulResource 
     | 
|
| 
       123 
125 
     | 
    
         
             
                                                                    faraday_options: faraday_options
         
     | 
| 
       124 
126 
     | 
    
         
             
                                                                   )
         
     | 
| 
       125 
127 
     | 
    
         | 
| 
      
 128 
     | 
    
         
            +
                  @connection.headers.merge!(default_headers)
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
       126 
130 
     | 
    
         
             
                  if auth_token
         
     | 
| 
       127 
131 
     | 
    
         
             
                    @connection.headers[:authorization] = "Bearer #{auth_token}"
         
     | 
| 
       128 
132 
     | 
    
         
             
                  elsif username && password
         
     | 
    
        data/restful_resource.gemspec
    CHANGED
    
    | 
         @@ -27,7 +27,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       27 
27 
     | 
    
         
             
              spec.add_development_dependency 'rspec_junit_formatter'
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
              spec.add_dependency 'activesupport', '>= 6', '< 8'
         
     | 
| 
       30 
     | 
    
         
            -
              spec.add_dependency 'faraday', '~> 1. 
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_dependency 'faraday', '~> 1.10'
         
     | 
| 
       31 
31 
     | 
    
         
             
              spec.add_dependency 'faraday-cdn-metrics', '~> 0.2'
         
     | 
| 
       32 
32 
     | 
    
         
             
              spec.add_dependency 'faraday-encoding'
         
     | 
| 
       33 
33 
     | 
    
         
             
              spec.add_dependency 'faraday-http-cache', '~> 2.2'
         
     | 
| 
         @@ -390,33 +390,38 @@ RSpec.describe RestfulResource::Base do 
     | 
|
| 
       390 
390 
     | 
    
         
             
                let(:open_timeout) { double }
         
     | 
| 
       391 
391 
     | 
    
         
             
                let(:faraday_config) { double }
         
     | 
| 
       392 
392 
     | 
    
         
             
                let(:faraday_options) { double }
         
     | 
| 
      
 393 
     | 
    
         
            +
                let(:default_headers) { double }
         
     | 
| 
       393 
394 
     | 
    
         | 
| 
       394 
395 
     | 
    
         
             
                it 'passes arguments to HttpClient' do
         
     | 
| 
       395 
396 
     | 
    
         
             
                  client = Class.new(described_class)
         
     | 
| 
       396 
     | 
    
         
            -
                  expect(RestfulResource::HttpClient).to receive(:new).with( 
     | 
| 
       397 
     | 
    
         
            -
             
     | 
| 
       398 
     | 
    
         
            -
             
     | 
| 
       399 
     | 
    
         
            -
             
     | 
| 
       400 
     | 
    
         
            -
             
     | 
| 
       401 
     | 
    
         
            -
             
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
             
     | 
| 
       404 
     | 
    
         
            -
             
     | 
| 
       405 
     | 
    
         
            -
             
     | 
| 
       406 
     | 
    
         
            -
             
     | 
| 
       407 
     | 
    
         
            -
             
     | 
| 
       408 
     | 
    
         
            -
                   
     | 
| 
       409 
     | 
    
         
            -
             
     | 
| 
       410 
     | 
    
         
            -
             
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
             
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
             
     | 
| 
       416 
     | 
    
         
            -
             
     | 
| 
       417 
     | 
    
         
            -
             
     | 
| 
       418 
     | 
    
         
            -
             
     | 
| 
       419 
     | 
    
         
            -
             
     | 
| 
      
 397 
     | 
    
         
            +
                  expect(RestfulResource::HttpClient).to receive(:new).with(
         
     | 
| 
      
 398 
     | 
    
         
            +
                    username: username,
         
     | 
| 
      
 399 
     | 
    
         
            +
                    password: password,
         
     | 
| 
      
 400 
     | 
    
         
            +
                    auth_token: auth_token,
         
     | 
| 
      
 401 
     | 
    
         
            +
                    logger: logger,
         
     | 
| 
      
 402 
     | 
    
         
            +
                    cache_store: cache_store,
         
     | 
| 
      
 403 
     | 
    
         
            +
                    instrumentation: instrumentation,
         
     | 
| 
      
 404 
     | 
    
         
            +
                    timeout: timeout,
         
     | 
| 
      
 405 
     | 
    
         
            +
                    open_timeout: open_timeout,
         
     | 
| 
      
 406 
     | 
    
         
            +
                    faraday_config: faraday_config,
         
     | 
| 
      
 407 
     | 
    
         
            +
                    faraday_options: faraday_options,
         
     | 
| 
      
 408 
     | 
    
         
            +
                    default_headers: default_headers
         
     | 
| 
      
 409 
     | 
    
         
            +
                  )
         
     | 
| 
      
 410 
     | 
    
         
            +
             
     | 
| 
      
 411 
     | 
    
         
            +
                  client.configure(
         
     | 
| 
      
 412 
     | 
    
         
            +
                    base_url: 'http://foo.bar',
         
     | 
| 
      
 413 
     | 
    
         
            +
                    username: username,
         
     | 
| 
      
 414 
     | 
    
         
            +
                    password: password,
         
     | 
| 
      
 415 
     | 
    
         
            +
                    auth_token: auth_token,
         
     | 
| 
      
 416 
     | 
    
         
            +
                    logger: logger,
         
     | 
| 
      
 417 
     | 
    
         
            +
                    cache_store: cache_store,
         
     | 
| 
      
 418 
     | 
    
         
            +
                    instrumentation: instrumentation,
         
     | 
| 
      
 419 
     | 
    
         
            +
                    timeout: timeout,
         
     | 
| 
      
 420 
     | 
    
         
            +
                    open_timeout: open_timeout,
         
     | 
| 
      
 421 
     | 
    
         
            +
                    faraday_config: faraday_config,
         
     | 
| 
      
 422 
     | 
    
         
            +
                    faraday_options: faraday_options,
         
     | 
| 
      
 423 
     | 
    
         
            +
                    default_headers: default_headers
         
     | 
| 
      
 424 
     | 
    
         
            +
                  )
         
     | 
| 
       420 
425 
     | 
    
         
             
                end
         
     | 
| 
       421 
426 
     | 
    
         
             
              end
         
     | 
| 
       422 
427 
     | 
    
         | 
| 
         @@ -271,4 +271,16 @@ RSpec.describe RestfulResource::HttpClient do 
     | 
|
| 
       271 
271 
     | 
    
         
             
                  expect(response.status).to eq 200
         
     | 
| 
       272 
272 
     | 
    
         
             
                end
         
     | 
| 
       273 
273 
     | 
    
         
             
              end
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
              describe 'default headers' do
         
     | 
| 
      
 276 
     | 
    
         
            +
                it 'uses default headers' do
         
     | 
| 
      
 277 
     | 
    
         
            +
                  connection = faraday_connection do |stubs|
         
     | 
| 
      
 278 
     | 
    
         
            +
                    stubs.get('http://httpbin.org/get', 'Foo' => 'bar') { |_env| [200, {}, nil] }
         
     | 
| 
      
 279 
     | 
    
         
            +
                  end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                  response = described_class.new(connection: connection, default_headers: { foo: 'bar' }).get('http://httpbin.org/get')
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
                  expect(response.status).to eq 200
         
     | 
| 
      
 284 
     | 
    
         
            +
                end
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
       274 
286 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: restful_resource
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.15.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - David Santoro
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Federico Rebora
         
     | 
| 
       9 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2024-01-22 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -135,14 +135,14 @@ dependencies: 
     | 
|
| 
       135 
135 
     | 
    
         
             
                requirements:
         
     | 
| 
       136 
136 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       137 
137 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       138 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 138 
     | 
    
         
            +
                    version: '1.10'
         
     | 
| 
       139 
139 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       140 
140 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       141 
141 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       142 
142 
     | 
    
         
             
                requirements:
         
     | 
| 
       143 
143 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       144 
144 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       145 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 145 
     | 
    
         
            +
                    version: '1.10'
         
     | 
| 
       146 
146 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       147 
147 
     | 
    
         
             
              name: faraday-cdn-metrics
         
     | 
| 
       148 
148 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -297,7 +297,7 @@ homepage: http://www.github.com/carwow/restful_resource 
     | 
|
| 
       297 
297 
     | 
    
         
             
            licenses:
         
     | 
| 
       298 
298 
     | 
    
         
             
            - MIT
         
     | 
| 
       299 
299 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       300 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 300 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       301 
301 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       302 
302 
     | 
    
         
             
            require_paths:
         
     | 
| 
       303 
303 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -313,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       313 
313 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       314 
314 
     | 
    
         
             
            requirements: []
         
     | 
| 
       315 
315 
     | 
    
         
             
            rubygems_version: 3.1.6
         
     | 
| 
       316 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 316 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       317 
317 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       318 
318 
     | 
    
         
             
            summary: A simple activerecord inspired rest resource base class implemented using
         
     | 
| 
       319 
319 
     | 
    
         
             
              rest-client
         
     |