restful_resource 2.16.0 → 2.18.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: 9f8db280a4d7afd8d96673bd146fc9ef8f07b65892c51510b96528cf14da3ef6
4
- data.tar.gz: 90117d3293b54c29bd95e898e74c5bf4a36729aa3699febefe1611f7c0edd2b3
3
+ metadata.gz: 4f45c7bb4d3a312e9e03f80bb613672260ea6db0d7eb025cd5b8f8e347c242ff
4
+ data.tar.gz: 5afb32e079d5006ca35680ae356ca657d4e66bee19432a3a797a0a377dea0ac6
5
5
  SHA512:
6
- metadata.gz: c75d4f211b12a0ba6a80911d86797317332343d36e293f4374612877c2e154ab963a45bc20a4916e8868c8c37b68c3d6d1716e97542ee7898c72622c539b648c
7
- data.tar.gz: ced11a5b38856a0401f9380dcada04089ed5ac929f275a1bef34b13906944357c874ba7395e88a661cbcc791119920967c0c7736151c2c10dc1a328439e46545
6
+ metadata.gz: b3b92083d51ee14c66d5f8640b56119d734b277a1a0cde77f6b44f8f18dfaa90f71a66d53b696a3b8c53734d78952032a0da1d746055e84cf6ce82abe54195ff
7
+ data.tar.gz: fcf23240eca478b98a05df1fc26680c1028873da7b9588c96635fab52be1bb91811cf8ac30f94a5b60c7a445e0daf162b43764ceca9503f9a3c862c5e386b6b8
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
1
  # Changelog
2
+ 2.18
3
+ ---
4
+
5
+ - Configure Faraday's default adapter as `net_http`
6
+ - Fix `X-Client-Start` & `X-Client-Timeout` headers to be strings not integers
7
+
8
+ 2.17
9
+ ---
10
+
11
+ - Re-add deprecation for :dig and :[] since they are still used by some clients
12
+
2
13
  2.16
3
14
  ---
4
15
 
@@ -2,6 +2,8 @@ module RestfulResource
2
2
  class Base < OpenObject
3
3
  extend RestfulResource::Associations
4
4
 
5
+ Deprecator = ActiveSupport::Deprecation.new('soon', 'restful_resource')
6
+
5
7
  def self.configure(base_url: nil,
6
8
  username: nil,
7
9
  password: nil,
@@ -1,6 +1,3 @@
1
- # Use the Faraday-Typhoeus adapter provided by Typhoeus, not Faraday
2
- require 'typhoeus/adapters/faraday'
3
-
4
1
  module RestfulResource
5
2
  class HttpClient
6
3
  class HttpError < StandardError
@@ -240,7 +237,7 @@ module RestfulResource
240
237
  b.response :encoding
241
238
  b.use :gzip
242
239
 
243
- b.adapter :typhoeus
240
+ b.adapter Faraday.default_adapter
244
241
  end
245
242
  end
246
243
 
@@ -261,7 +258,7 @@ module RestfulResource
261
258
  req.url request.url
262
259
 
263
260
  req.headers = req.headers.merge(request.headers).merge(x_client_start: time_current_ms)
264
- req.headers = req.headers.merge(x_client_timeout: req.options[:timeout]) if req.options[:timeout]
261
+ req.headers = req.headers.merge(x_client_timeout: req.options[:timeout]&.to_s) if req.options[:timeout]
265
262
  end
266
263
 
267
264
  Response.new(body: response.body, headers: response.headers, status: response.status)
@@ -295,7 +292,7 @@ module RestfulResource
295
292
  end
296
293
 
297
294
  def time_current_ms
298
- (Time.current.to_f * 1_000.0).to_i
295
+ (Time.current.to_f * 1_000.0).to_i.to_s
299
296
  end
300
297
  end
301
298
  end
@@ -0,0 +1,7 @@
1
+ module RestfulResource
2
+ class Railtie < Rails::Railtie
3
+ initializer 'restful_resource.deprecator' do |app|
4
+ app.deprecators[:restful_resource] = Base::Deprecator
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module RestfulResource
2
2
  class StrictOpenStruct < ::OpenStruct
3
- undef_method :dig, :[]
3
+ deprecate :dig, :[], deprecator: Base::Deprecator
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module RestfulResource
2
- VERSION = '2.16.0'.freeze
2
+ VERSION = '2.18.0'.freeze
3
3
  end
@@ -24,3 +24,4 @@ require_relative 'restful_resource/redirections'
24
24
  require_relative 'restful_resource/instrumentation'
25
25
  require_relative 'restful_resource/base'
26
26
  require_relative 'restful_resource/strict_open_struct'
27
+ require_relative 'restful_resource/railtie' if defined?(Rails::Railtie)
@@ -34,5 +34,4 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'faraday_middleware', '~> 1.0'
35
35
  spec.add_dependency 'link_header'
36
36
  spec.add_dependency 'rack', '~> 2.2'
37
- spec.add_dependency 'typhoeus', '~> 1.4'
38
37
  end
@@ -18,8 +18,8 @@ describe RestfulResource::HttpClient do
18
18
  let(:middleware) { connection.builder.handlers }
19
19
 
20
20
  describe 'Builder configuration' do
21
- it 'uses the typhoeus adapter' do
22
- expect(connection.adapter).to eq Faraday::Adapter::Typhoeus
21
+ it 'uses the net http adapter' do
22
+ expect(connection.adapter).to eq Faraday::Adapter::NetHttp
23
23
  end
24
24
 
25
25
  it 'url_encodes requests' do
@@ -221,7 +221,7 @@ RSpec.describe RestfulResource::HttpClient do
221
221
 
222
222
  context 'when explicit timeout set on connection' do
223
223
  let(:timeout) { 5 }
224
- let(:required_headers) { { 'X-Client-Timeout' => 5 } }
224
+ let(:required_headers) { { 'X-Client-Timeout' => '5' } }
225
225
 
226
226
  it 'sets X-Client-Timeout correctly' do
227
227
  response = http_client.get('http://httpbin.org/get')
@@ -243,7 +243,7 @@ RSpec.describe RestfulResource::HttpClient do
243
243
 
244
244
  context 'when set on request' do
245
245
  let(:timeout) { nil }
246
- let(:required_headers) { { 'X-Client-Timeout' => 1 } }
246
+ let(:required_headers) { { 'X-Client-Timeout' => '1' } }
247
247
 
248
248
  it 'sets X-Client-Timeout correctly' do
249
249
  response = http_client.get('http://httpbin.org/get', timeout: 1)
@@ -255,7 +255,7 @@ RSpec.describe RestfulResource::HttpClient do
255
255
 
256
256
  describe 'X-Client-Start' do
257
257
  let(:now) { Time.current }
258
- let(:required_headers) { { 'X-Client-Start' => (now.to_f * 1000.0).to_i } }
258
+ let(:required_headers) { { 'X-Client-Start' => (now.to_f * 1000.0).to_i.to_s } }
259
259
  let(:http_client) { described_class.new(connection: connection) }
260
260
  let(:connection) do
261
261
  conn = faraday_connection do |stubs|
@@ -4,14 +4,18 @@ RSpec.describe RestfulResource::StrictOpenStruct do
4
4
  let(:instance) { described_class.new(foo: 'bar') }
5
5
 
6
6
  describe '#dig' do
7
- it 'is not defined' do
8
- expect { instance.dig(:foo) }.to raise_error(NoMethodError)
7
+ it 'is deprecated' do
8
+ expect { instance.dig(:foo) }.to output(
9
+ /dig is deprecated and will be removed from restful_resource soon/
10
+ ).to_stderr
9
11
  end
10
12
  end
11
13
 
12
14
  describe '#[]' do
13
- it 'is not defined' do
14
- expect { instance[:foo] }.to raise_error(NoMethodError)
15
+ it 'is deprecated' do
16
+ expect { instance[:foo] }.to output(
17
+ /\[\] is deprecated and will be removed from restful_resource soon/
18
+ ).to_stderr
15
19
  end
16
20
  end
17
21
  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.16.0
4
+ version: 2.18.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: 2024-03-05 00:00:00.000000000 Z
12
+ date: 2024-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -227,20 +227,6 @@ dependencies:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
229
  version: '2.2'
230
- - !ruby/object:Gem::Dependency
231
- name: typhoeus
232
- requirement: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: '1.4'
237
- type: :runtime
238
- prerelease: false
239
- version_requirements: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: '1.4'
244
230
  description: A simple activerecord inspired rest resource base class implemented using
245
231
  rest-client
246
232
  email:
@@ -273,6 +259,7 @@ files:
273
259
  - lib/restful_resource/paginated_array.rb
274
260
  - lib/restful_resource/parameter_missing_error.rb
275
261
  - lib/restful_resource/rails_validations.rb
262
+ - lib/restful_resource/railtie.rb
276
263
  - lib/restful_resource/redirections.rb
277
264
  - lib/restful_resource/request.rb
278
265
  - lib/restful_resource/resource_id_missing_error.rb
@@ -296,7 +283,7 @@ homepage: http://www.github.com/carwow/restful_resource
296
283
  licenses:
297
284
  - MIT
298
285
  metadata: {}
299
- post_install_message:
286
+ post_install_message:
300
287
  rdoc_options: []
301
288
  require_paths:
302
289
  - lib
@@ -311,8 +298,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
298
  - !ruby/object:Gem::Version
312
299
  version: '0'
313
300
  requirements: []
314
- rubygems_version: 3.4.19
315
- signing_key:
301
+ rubygems_version: 3.1.6
302
+ signing_key:
316
303
  specification_version: 4
317
304
  summary: A simple activerecord inspired rest resource base class implemented using
318
305
  rest-client