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 +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/restful_resource/base.rb +2 -0
- data/lib/restful_resource/http_client.rb +3 -6
- data/lib/restful_resource/railtie.rb +7 -0
- data/lib/restful_resource/strict_open_struct.rb +1 -1
- data/lib/restful_resource/version.rb +1 -1
- data/lib/restful_resource.rb +1 -0
- data/restful_resource.gemspec +0 -1
- data/spec/restful_resource/http_client_configuration_spec.rb +2 -2
- data/spec/restful_resource/http_client_spec.rb +3 -3
- data/spec/restful_resource/strict_open_struct_spec.rb +8 -4
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f45c7bb4d3a312e9e03f80bb613672260ea6db0d7eb025cd5b8f8e347c242ff
|
4
|
+
data.tar.gz: 5afb32e079d5006ca35680ae356ca657d4e66bee19432a3a797a0a377dea0ac6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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
|
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
|
data/lib/restful_resource.rb
CHANGED
@@ -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)
|
data/restful_resource.gemspec
CHANGED
@@ -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
|
22
|
-
expect(connection.adapter).to eq Faraday::Adapter::
|
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
|
8
|
-
expect { instance.dig(:foo) }.to
|
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
|
14
|
-
expect { instance[:foo] }.to
|
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.
|
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-
|
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.
|
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
|