faraday-http-cache 2.2.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +50 -10
- data/lib/faraday/http_cache/cache_control.rb +1 -0
- data/lib/faraday/http_cache/memory_store.rb +26 -0
- data/lib/faraday/http_cache/request.rb +2 -0
- data/lib/faraday/http_cache/response.rb +2 -1
- data/lib/faraday/http_cache/storage.rb +8 -186
- data/lib/faraday/http_cache/strategies/base_strategy.rb +94 -0
- data/lib/faraday/http_cache/strategies/by_url.rb +118 -0
- data/lib/faraday/http_cache/strategies/by_vary.rb +86 -0
- data/lib/faraday/http_cache/strategies.rb +4 -0
- data/lib/faraday/http_cache.rb +22 -19
- data/spec/binary_spec.rb +2 -1
- data/spec/cache_control_spec.rb +1 -0
- data/spec/http_cache_spec.rb +3 -12
- data/spec/instrumentation_spec.rb +1 -0
- data/spec/json_spec.rb +1 -0
- data/spec/request_spec.rb +1 -0
- data/spec/response_spec.rb +6 -5
- data/spec/spec_helper.rb +8 -3
- data/spec/storage_spec.rb +25 -8
- data/spec/strategies/base_strategy_spec.rb +27 -0
- data/spec/strategies/by_url_spec.rb +145 -0
- data/spec/strategies/by_vary_spec.rb +145 -0
- data/spec/support/test_app.rb +2 -1
- data/spec/support/test_server.rb +8 -6
- data/spec/validation_spec.rb +1 -0
- metadata +29 -18
data/spec/support/test_server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'net/http'
|
3
4
|
|
4
5
|
class TestServer
|
@@ -27,11 +28,11 @@ class TestServer
|
|
27
28
|
log = File.open('log/test.log', 'w+')
|
28
29
|
log.sync = true
|
29
30
|
webrick_opts = {
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
Port: @port,
|
32
|
+
Logger: WEBrick::Log.new(log),
|
33
|
+
AccessLog: [[log, '[%{X-Faraday-Adapter}i] %m %U -> %s %b']]
|
33
34
|
}
|
34
|
-
Rack::Handler::WEBrick.run(TestApp, webrick_opts)
|
35
|
+
Rack::Handler::WEBrick.run(TestApp, **webrick_opts)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -39,7 +40,7 @@ class TestServer
|
|
39
40
|
conn = Net::HTTP.new @host, @port
|
40
41
|
conn.open_timeout = conn.read_timeout = 0.1
|
41
42
|
|
42
|
-
responsive = ->(path) {
|
43
|
+
responsive = ->(path) {
|
43
44
|
begin
|
44
45
|
res = conn.start { conn.get(path) }
|
45
46
|
res.is_a?(Net::HTTPSuccess)
|
@@ -51,6 +52,7 @@ class TestServer
|
|
51
52
|
server_pings = 0
|
52
53
|
loop do
|
53
54
|
break if responsive.call('/ping')
|
55
|
+
|
54
56
|
server_pings += 1
|
55
57
|
sleep 0.05
|
56
58
|
abort 'test server did not managed to start' if server_pings >= 50
|
@@ -61,6 +63,6 @@ class TestServer
|
|
61
63
|
server = TCPServer.new(@host, 0)
|
62
64
|
server.addr[1]
|
63
65
|
ensure
|
64
|
-
server
|
66
|
+
server&.close
|
65
67
|
end
|
66
68
|
end
|
data/spec/validation_spec.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-http-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Mazza
|
8
8
|
- George Guimarães
|
9
|
-
|
9
|
+
- Gustavo Araujo
|
10
|
+
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: faraday
|
@@ -37,9 +38,14 @@ files:
|
|
37
38
|
- lib/faraday-http-cache.rb
|
38
39
|
- lib/faraday/http_cache.rb
|
39
40
|
- lib/faraday/http_cache/cache_control.rb
|
41
|
+
- lib/faraday/http_cache/memory_store.rb
|
40
42
|
- lib/faraday/http_cache/request.rb
|
41
43
|
- lib/faraday/http_cache/response.rb
|
42
44
|
- lib/faraday/http_cache/storage.rb
|
45
|
+
- lib/faraday/http_cache/strategies.rb
|
46
|
+
- lib/faraday/http_cache/strategies/base_strategy.rb
|
47
|
+
- lib/faraday/http_cache/strategies/by_url.rb
|
48
|
+
- lib/faraday/http_cache/strategies/by_vary.rb
|
43
49
|
- spec/binary_spec.rb
|
44
50
|
- spec/cache_control_spec.rb
|
45
51
|
- spec/http_cache_spec.rb
|
@@ -49,15 +55,18 @@ files:
|
|
49
55
|
- spec/response_spec.rb
|
50
56
|
- spec/spec_helper.rb
|
51
57
|
- spec/storage_spec.rb
|
58
|
+
- spec/strategies/base_strategy_spec.rb
|
59
|
+
- spec/strategies/by_url_spec.rb
|
60
|
+
- spec/strategies/by_vary_spec.rb
|
52
61
|
- spec/support/empty.png
|
53
62
|
- spec/support/test_app.rb
|
54
63
|
- spec/support/test_server.rb
|
55
64
|
- spec/validation_spec.rb
|
56
65
|
homepage: https://github.com/sourcelevel/faraday-http-cache
|
57
66
|
licenses:
|
58
|
-
- Apache
|
67
|
+
- Apache-2.0
|
59
68
|
metadata: {}
|
60
|
-
post_install_message:
|
69
|
+
post_install_message:
|
61
70
|
rdoc_options: []
|
62
71
|
require_paths:
|
63
72
|
- lib
|
@@ -65,29 +74,31 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
74
|
requirements:
|
66
75
|
- - ">="
|
67
76
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
77
|
+
version: 2.4.0
|
69
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
79
|
requirements:
|
71
80
|
- - ">="
|
72
81
|
- !ruby/object:Gem::Version
|
73
82
|
version: '0'
|
74
83
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
84
|
+
rubygems_version: 3.2.3
|
85
|
+
signing_key:
|
78
86
|
specification_version: 4
|
79
87
|
summary: A Faraday middleware that stores and validates cache expiration.
|
80
88
|
test_files:
|
81
|
-
- spec/
|
82
|
-
- spec/
|
83
|
-
- spec/
|
89
|
+
- spec/binary_spec.rb
|
90
|
+
- spec/cache_control_spec.rb
|
91
|
+
- spec/http_cache_spec.rb
|
84
92
|
- spec/instrumentation_spec.rb
|
93
|
+
- spec/json_spec.rb
|
94
|
+
- spec/request_spec.rb
|
95
|
+
- spec/response_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
85
97
|
- spec/storage_spec.rb
|
86
|
-
- spec/
|
87
|
-
- spec/
|
88
|
-
- spec/
|
98
|
+
- spec/strategies/base_strategy_spec.rb
|
99
|
+
- spec/strategies/by_url_spec.rb
|
100
|
+
- spec/strategies/by_vary_spec.rb
|
89
101
|
- spec/support/empty.png
|
102
|
+
- spec/support/test_app.rb
|
90
103
|
- spec/support/test_server.rb
|
91
|
-
- spec/
|
92
|
-
- spec/cache_control_spec.rb
|
93
|
-
- spec/response_spec.rb
|
104
|
+
- spec/validation_spec.rb
|