flexirest 1.10.12 → 1.11.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/.github/workflows/build.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/flexirest.gemspec +17 -26
- data/lib/flexirest/base_without_validation.rb +1 -1
- data/lib/flexirest/caching.rb +2 -2
- data/lib/flexirest/connection_manager.rb +1 -1
- data/lib/flexirest/request.rb +1 -1
- data/lib/flexirest/version.rb +1 -1
- data/spec/lib/connection_manager_spec.rb +3 -1
- data/spec/lib/connection_spec.rb +18 -7
- data/spec/lib/instrumentation_spec.rb +3 -0
- metadata +20 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3c99c9dcb4b2b2d6b4992a53d138877f251f0810bb94dc11faf9d9e1b89f9cb
|
|
4
|
+
data.tar.gz: 22554cafc10d12337c1511828ab27471dbadf36de4e211c5383eae96c4fb4c34
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cf855f9fbc7d4f213a19840e11cfa9b816de9b1a0750726538f288f559ec150c7a05a4ae8b63297e8aedcf8002103e2e4ae275cb497793144c83aebc7f7577e
|
|
7
|
+
data.tar.gz: e1a5b90ace51f341a340e5ed32f5c8afc30f2784a38cf7281c621157a8b1233da9b81180ed6a5dc0694f4ac72933793b9e47dcf01d9389583b02bdd7dc3aefbd
|
data/.github/workflows/build.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.0
|
|
4
|
+
|
|
5
|
+
Major change:
|
|
6
|
+
|
|
7
|
+
- Dropped support for Ruby 2.x. Ruby 2.7 will be EOL in 27 days, and anyone can use the previous version 1.10 if they need 2.x support for the last month.
|
|
8
|
+
|
|
9
|
+
Enhancement:
|
|
10
|
+
|
|
11
|
+
- Added caching lines to the quiet! feature (thanks to Romain Gisiger for the issue and PR)
|
|
12
|
+
|
|
3
13
|
## 1.10.12
|
|
4
14
|
|
|
5
15
|
Enhancement:
|
data/flexirest.gemspec
CHANGED
|
@@ -4,15 +4,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'flexirest/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name
|
|
8
|
-
spec.version
|
|
9
|
-
spec.
|
|
10
|
-
spec.
|
|
11
|
-
spec.
|
|
12
|
-
spec.
|
|
13
|
-
spec.
|
|
14
|
-
spec.
|
|
15
|
-
spec.
|
|
7
|
+
spec.name = "flexirest"
|
|
8
|
+
spec.version = Flexirest::VERSION
|
|
9
|
+
spec.required_ruby_version = ">= 3.0.0"
|
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
|
11
|
+
spec.authors = ["Andy Jeffries"]
|
|
12
|
+
spec.email = ["andy@andyjeffries.co.uk"]
|
|
13
|
+
spec.description = %q{Accessing REST services in a flexible way}
|
|
14
|
+
spec.summary = %q{This gem is for accessing REST services in a flexible way. ActiveResource already exists for this, but it doesn't work where the resource naming doesn't follow Rails conventions, it doesn't have in-built caching and it's not as flexible in general.}
|
|
15
|
+
spec.homepage = "https://andyjeffries.co.uk/"
|
|
16
|
+
spec.license = "MIT"
|
|
16
17
|
|
|
17
18
|
if spec.respond_to?(:metadata)
|
|
18
19
|
spec.metadata["source_code_uri"] = "https://github.com/flexirest/flexirest"
|
|
@@ -26,31 +27,21 @@ Gem::Specification.new do |spec|
|
|
|
26
27
|
spec.add_development_dependency "bundler"
|
|
27
28
|
spec.add_development_dependency "rake"
|
|
28
29
|
spec.add_development_dependency "rspec", "~> 3"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
spec.add_development_dependency "rspec_junit_formatter", "= 0.2.3"
|
|
32
|
-
else
|
|
33
|
-
spec.add_development_dependency "webmock"
|
|
34
|
-
spec.add_development_dependency "rspec_junit_formatter"
|
|
35
|
-
end
|
|
30
|
+
spec.add_development_dependency "webmock"
|
|
31
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
|
36
32
|
spec.add_development_dependency "simplecov"
|
|
37
33
|
spec.add_development_dependency "simplecov-rcov"
|
|
38
34
|
spec.add_development_dependency 'coveralls'
|
|
39
|
-
spec.add_development_dependency "api-auth", ">=
|
|
40
|
-
spec.add_development_dependency 'typhoeus'
|
|
35
|
+
spec.add_development_dependency "api-auth", ">= 2.4"
|
|
36
|
+
spec.add_development_dependency 'faraday-typhoeus'
|
|
41
37
|
spec.add_development_dependency 'activemodel'
|
|
42
38
|
spec.add_development_dependency 'rest-client'
|
|
43
39
|
|
|
44
40
|
spec.add_runtime_dependency "mime-types"
|
|
45
41
|
spec.add_runtime_dependency "multi_json"
|
|
46
42
|
spec.add_runtime_dependency "crack"
|
|
47
|
-
spec.add_runtime_dependency "faraday", "~>
|
|
43
|
+
spec.add_runtime_dependency "faraday", "~> 2.7"
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2')
|
|
52
|
-
spec.add_runtime_dependency "activesupport"
|
|
53
|
-
else
|
|
54
|
-
spec.add_runtime_dependency "activesupport", "< 5.0.0"
|
|
55
|
-
end
|
|
45
|
+
spec.add_runtime_dependency "activesupport"
|
|
46
|
+
spec.add_runtime_dependency "actionpack"
|
|
56
47
|
end
|
|
@@ -220,7 +220,7 @@ module Flexirest
|
|
|
220
220
|
if value.is_a?(String) && value.length > 50
|
|
221
221
|
"#{value[0..50]}...".inspect
|
|
222
222
|
elsif value.is_a?(Date) || value.is_a?(Time)
|
|
223
|
-
%("#{value.to_s(:db)}")
|
|
223
|
+
%("#{value.respond_to?(:to_fs) ? value.to_fs(:db) : value.to_s(:db)}")
|
|
224
224
|
else
|
|
225
225
|
value.inspect
|
|
226
226
|
end
|
data/lib/flexirest/caching.rb
CHANGED
|
@@ -57,7 +57,7 @@ module Flexirest
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
def write_cached_response(request, response, result)
|
|
60
|
+
def write_cached_response(request, response, result, quiet)
|
|
61
61
|
return if result.is_a? Symbol
|
|
62
62
|
return unless perform_caching
|
|
63
63
|
return unless !result.respond_to?(:_status) || [200, 304].include?(result._status)
|
|
@@ -69,7 +69,7 @@ module Flexirest
|
|
|
69
69
|
|
|
70
70
|
if cache_store && (headers[:etag] || headers[:expires])
|
|
71
71
|
key = "#{request.class_name}:#{request.original_url}"
|
|
72
|
-
Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Writing to cache"
|
|
72
|
+
Flexirest::Logger.debug " \033[1;4;32m#{Flexirest.name}\033[0m #{key} - Writing to cache" unless quiet
|
|
73
73
|
cached_response = CachedResponse.new(status:response.status, result:result, response_headers: headers)
|
|
74
74
|
cached_response.etag = "#{headers[:etag]}" if headers[:etag]
|
|
75
75
|
cached_response.expires = Time.parse(headers[:expires]) rescue nil if headers[:expires]
|
|
@@ -20,7 +20,7 @@ module Flexirest
|
|
|
20
20
|
def self.in_parallel(base_url)
|
|
21
21
|
begin
|
|
22
22
|
require 'typhoeus'
|
|
23
|
-
require 'typhoeus/adapters/faraday'
|
|
23
|
+
require 'typhoeus/adapters/faraday' unless Gem.loaded_specs["faraday-typhoeus"].present?
|
|
24
24
|
rescue LoadError
|
|
25
25
|
raise MissingOptionalLibraryError.new("To call '::Flexirest::ConnectionManager.in_parallel' you must include the gem 'Typhoeus' in your Gemfile.")
|
|
26
26
|
end
|
data/lib/flexirest/request.rb
CHANGED
|
@@ -320,7 +320,7 @@ module Flexirest
|
|
|
320
320
|
|
|
321
321
|
result = handle_response(response_env, cached)
|
|
322
322
|
@response_delegate.__setobj__(result)
|
|
323
|
-
original_object_class.write_cached_response(self, response_env, result) unless @method[:options][:skip_caching]
|
|
323
|
+
original_object_class.write_cached_response(self, response_env, result, quiet?) unless @method[:options][:skip_caching]
|
|
324
324
|
end
|
|
325
325
|
|
|
326
326
|
# If this was not a parallel request just return the original result
|
data/lib/flexirest/version.rb
CHANGED
|
@@ -35,13 +35,15 @@ describe Flexirest::ConnectionManager do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "should call 'in_parallel' for a session and yield procedure inside that block" do
|
|
38
|
+
require 'faraday/typhoeus' if Gem.loaded_specs["faraday-typhoeus"].present?
|
|
38
39
|
Flexirest::Base.adapter = :typhoeus
|
|
39
40
|
Flexirest::ConnectionManager.get_connection("http://www.example.com").session
|
|
40
41
|
expect { |b| Flexirest::ConnectionManager.in_parallel("http://www.example.com", &b)}.to yield_control
|
|
41
42
|
Flexirest::Base._reset_configuration!
|
|
42
43
|
end
|
|
43
44
|
|
|
44
|
-
it "should raise Flexirest::MissingOptionalLibraryError if
|
|
45
|
+
it "should raise Flexirest::MissingOptionalLibraryError if Typhoeus isn't available" do
|
|
46
|
+
require 'faraday/typhoeus' if Gem.loaded_specs["faraday-typhoeus"].present?
|
|
45
47
|
Flexirest::Base.adapter = :typhoeus
|
|
46
48
|
Flexirest::ConnectionManager.get_connection("http://www.example.com").session
|
|
47
49
|
expect(Flexirest::ConnectionManager).to receive(:require).and_raise(LoadError)
|
data/spec/lib/connection_spec.rb
CHANGED
|
@@ -175,13 +175,24 @@ describe Flexirest::Connection do
|
|
|
175
175
|
expect(auth_header == "APIAuth id123:TQiQIW6vVaDC5jvh99uTNkxIg6Q=" || auth_header == "APIAuth id123:PMWBThkB8vKbvUccHvoqu9G3eVk=").to be_truthy
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s < "2.5.0"
|
|
179
|
+
it 'should have an Content-MD5 header' do
|
|
180
|
+
stub_request(:put, "www.example.com/foo").
|
|
181
|
+
with(body: "body", :headers => @default_headers).
|
|
182
|
+
to_return(body: "{result:true}")
|
|
183
|
+
|
|
184
|
+
result = @connection.put("/foo", "body", @options)
|
|
185
|
+
expect(result.env.request_headers['Content-MD5']).to eq("hBotaJrYa9FhFEdFPCLG/A==")
|
|
186
|
+
end
|
|
187
|
+
else
|
|
188
|
+
it 'should have an X-AUTHORIZATION-CONTENT-SHA256 header' do
|
|
189
|
+
stub_request(:put, "www.example.com/foo").
|
|
190
|
+
with(body: "body", :headers => @default_headers).
|
|
191
|
+
to_return(body: "{result:true}")
|
|
192
|
+
|
|
193
|
+
result = @connection.put("/foo", "body", @options)
|
|
194
|
+
expect(result.env.request_headers['X-AUTHORIZATION-CONTENT-SHA256']).to eq("Iw2DWNyOiJC0xY3utikS7i8gNXrpKlzIYbmOaP4xrLU=")
|
|
195
|
+
end
|
|
185
196
|
end
|
|
186
197
|
end
|
|
187
198
|
|
|
@@ -10,6 +10,9 @@ describe Flexirest::Instrumentation do
|
|
|
10
10
|
it "should save a load hook to include the instrumentation" do
|
|
11
11
|
hook_tester = double("HookTester")
|
|
12
12
|
expect(hook_tester).to receive(:include).with(Flexirest::ControllerInstrumentation)
|
|
13
|
+
if Gem.loaded_specs["api-auth"].present? && Gem.loaded_specs["api-auth"].version.to_s >= "2.5.0"
|
|
14
|
+
require "action_controller"
|
|
15
|
+
end
|
|
13
16
|
ActiveSupport.run_load_hooks(:action_controller, hook_tester)
|
|
14
17
|
end
|
|
15
18
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flexirest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Jeffries
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-03-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -127,9 +127,6 @@ dependencies:
|
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|
|
130
|
-
- !ruby/object:Gem::Version
|
|
131
|
-
version: 1.3.1
|
|
132
|
-
- - "<"
|
|
133
130
|
- !ruby/object:Gem::Version
|
|
134
131
|
version: '2.4'
|
|
135
132
|
type: :development
|
|
@@ -137,13 +134,10 @@ dependencies:
|
|
|
137
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
138
135
|
requirements:
|
|
139
136
|
- - ">="
|
|
140
|
-
- !ruby/object:Gem::Version
|
|
141
|
-
version: 1.3.1
|
|
142
|
-
- - "<"
|
|
143
137
|
- !ruby/object:Gem::Version
|
|
144
138
|
version: '2.4'
|
|
145
139
|
- !ruby/object:Gem::Dependency
|
|
146
|
-
name: typhoeus
|
|
140
|
+
name: faraday-typhoeus
|
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
|
148
142
|
requirements:
|
|
149
143
|
- - ">="
|
|
@@ -232,14 +226,14 @@ dependencies:
|
|
|
232
226
|
requirements:
|
|
233
227
|
- - "~>"
|
|
234
228
|
- !ruby/object:Gem::Version
|
|
235
|
-
version: '
|
|
229
|
+
version: '2.7'
|
|
236
230
|
type: :runtime
|
|
237
231
|
prerelease: false
|
|
238
232
|
version_requirements: !ruby/object:Gem::Requirement
|
|
239
233
|
requirements:
|
|
240
234
|
- - "~>"
|
|
241
235
|
- !ruby/object:Gem::Version
|
|
242
|
-
version: '
|
|
236
|
+
version: '2.7'
|
|
243
237
|
- !ruby/object:Gem::Dependency
|
|
244
238
|
name: activesupport
|
|
245
239
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -254,6 +248,20 @@ dependencies:
|
|
|
254
248
|
- - ">="
|
|
255
249
|
- !ruby/object:Gem::Version
|
|
256
250
|
version: '0'
|
|
251
|
+
- !ruby/object:Gem::Dependency
|
|
252
|
+
name: actionpack
|
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
|
254
|
+
requirements:
|
|
255
|
+
- - ">="
|
|
256
|
+
- !ruby/object:Gem::Version
|
|
257
|
+
version: '0'
|
|
258
|
+
type: :runtime
|
|
259
|
+
prerelease: false
|
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
261
|
+
requirements:
|
|
262
|
+
- - ">="
|
|
263
|
+
- !ruby/object:Gem::Version
|
|
264
|
+
version: '0'
|
|
257
265
|
description: Accessing REST services in a flexible way
|
|
258
266
|
email:
|
|
259
267
|
- andy@andyjeffries.co.uk
|
|
@@ -378,7 +386,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
378
386
|
requirements:
|
|
379
387
|
- - ">="
|
|
380
388
|
- !ruby/object:Gem::Version
|
|
381
|
-
version:
|
|
389
|
+
version: 3.0.0
|
|
382
390
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
383
391
|
requirements:
|
|
384
392
|
- - ">="
|