restful_resource 2.13.4 → 2.15.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
  SHA256:
3
- metadata.gz: 811b916cd8a44f9a8c94185176a2a99e55719dbe7320c8772efb856a5fb17229
4
- data.tar.gz: '08eec998987cefdee15d7816c5b3ee801d9a7f0e5f5f609d5ee5fade7ad6ee7b'
3
+ metadata.gz: 7af1361039382e70e477e2092457d8d816ed698a2c1e04395eb970fbfd491fde
4
+ data.tar.gz: dc56db8631527d46c3e670e338eb5272881233ae50b528cb4e50faaf8a87de46
5
5
  SHA512:
6
- metadata.gz: 6a1bc2e111f392ec4d50a41225b1534b1a6f19bc36d730cbad3047b793624fc0022d9d293be7578ed9886eceb90ed744a94daa7b4239cd68ed83fefe78f982c5
7
- data.tar.gz: 84684eba6db73549f8b116d7637e2502b7a6721214c10bc1aab4c0adff1a6aca6755a104efb57ea11f9ed7195502aa9177a3b9bd83c8f04f51083e2155ce86dd
6
+ metadata.gz: a0532d37adbb89b6f53d98a359c3c54f52a11b26d0c7d1ac7b58b814e1831e8ab9825156d9f61676fff0c5c7afb2ede67dff28689922d8cac2bd5680439ef00a
7
+ data.tar.gz: 357089f436e9d7b984a053f1fcc7642366220033a6e5ffdd6e05a1e37096714eff50130e0a1129b97c1393849392f976437f15311ea50edea31398ff794b3b0b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
1
  # Changelog
2
+ 2.15
3
+ ---
4
+
5
+ - Bump `faraday` to a minimum of `1.10` to resolve dependency issues
6
+
7
+ 2.14
8
+ ---
9
+
10
+ - Added support for default headers when configuring a `RestfulResource::Base`
11
+
2
12
  2.13.4
3
13
  ---
4
14
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.13.4'.freeze
2
+ VERSION = '2.15.0'.freeze
3
3
  end
@@ -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.0'
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(username: username,
397
- password: password,
398
- auth_token: auth_token,
399
- logger: logger,
400
- cache_store: cache_store,
401
- instrumentation: instrumentation,
402
- timeout: timeout,
403
- open_timeout: open_timeout,
404
- faraday_config: faraday_config,
405
- faraday_options: faraday_options
406
- )
407
-
408
- client.configure(base_url: 'http://foo.bar',
409
- username: username,
410
- password: password,
411
- auth_token: auth_token,
412
- logger: logger,
413
- cache_store: cache_store,
414
- instrumentation: instrumentation,
415
- timeout: timeout,
416
- open_timeout: open_timeout,
417
- faraday_config: faraday_config,
418
- faraday_options: faraday_options
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.13.4
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: 2023-03-02 00:00:00.000000000 Z
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.0'
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.0'
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