rack-cache 1.9.0 → 1.10.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: d5127a4c26d9bf722dffb6743e6d0231f623ce59348ba3eba525867cb2cc3fc9
4
- data.tar.gz: 474db5a34c1ac449c871e76f5716f717102d4adf27af5fe7190d3523293202e6
3
+ metadata.gz: c3812540d0f5bbe2e962a141bfec32689f6fd91eba903f450bacca8b7ba3ac8e
4
+ data.tar.gz: e688349a29392080fdf0e906f262675bff93af5831336370ef5a2b88aa5838ac
5
5
  SHA512:
6
- metadata.gz: f66cdddd9326db331ac3bfc50eda836ae87ae1f596803bee7203a232d457bcf97c2b26c6a0575cee69252c5e9c8122bed4e6fd00b387002127300b17bb0a4cae
7
- data.tar.gz: ee479aacff602c4ca20856b73508a9a795ad1eabf1d08e7221be4b5877fd16ab6d31fb4f91b39f38d599ba934022a722b3bf15106e34c765e667f6a9b67b5bf7
6
+ metadata.gz: f411e9b9678e5e3d4c80623a0d2bede18b2f024ed9e8d7e9d78e114f3fb69278f46ca2cf2281e9ca7260a4a4f3c6225f8ebbc8116aabb5ffa4b2ba8e6ceb6d20
7
+ data.tar.gz: 51105145c2d3fb9c9106bb77e71254f002e416a0978f1a0d788e674ba73ba87645c387c86b875b4c7973ba32f6a1cb89f35e8c1102904e1258d3f91060a929e0
@@ -19,6 +19,7 @@ module Rack::Cache
19
19
  @backend = backend
20
20
  @trace = []
21
21
  @env = nil
22
+ @options = options
22
23
 
23
24
  initialize_options options
24
25
  yield self if block_given?
@@ -31,14 +32,14 @@ module Rack::Cache
31
32
  # value effects the result of this method immediately.
32
33
  def metastore
33
34
  uri = options['rack-cache.metastore']
34
- storage.resolve_metastore_uri(uri)
35
+ storage.resolve_metastore_uri(uri, @options)
35
36
  end
36
37
 
37
38
  # The configured EntityStore instance. Changing the rack-cache.entitystore
38
39
  # value effects the result of this method immediately.
39
40
  def entitystore
40
41
  uri = options['rack-cache.entitystore']
41
- storage.resolve_entitystore_uri(uri)
42
+ storage.resolve_entitystore_uri(uri, @options)
42
43
  end
43
44
 
44
45
  # The Rack call interface. The receiver acts as a prototype and runs
@@ -33,10 +33,10 @@ module Rack::Cache
33
33
 
34
34
  # Stores entity bodies on the heap using a Hash object.
35
35
  class Heap < EntityStore
36
-
37
36
  # Create the store with the specified backing Hash.
38
- def initialize(hash={})
37
+ def initialize(hash={}, options = {})
39
38
  @hash = hash
39
+ @options = options
40
40
  end
41
41
 
42
42
  # Determine whether the response body with the specified key (SHA1)
@@ -71,8 +71,8 @@ module Rack::Cache
71
71
  nil
72
72
  end
73
73
 
74
- def self.resolve(uri)
75
- new
74
+ def self.resolve(uri, options = {})
75
+ new({}, options)
76
76
  end
77
77
  end
78
78
 
@@ -198,8 +198,9 @@ module Rack::Cache
198
198
  # Concrete MetaStore implementation that uses a simple Hash to store
199
199
  # request/response pairs on the heap.
200
200
  class Heap < MetaStore
201
- def initialize(hash={})
201
+ def initialize(hash={}, options = {})
202
202
  @hash = hash
203
+ @options = options
203
204
  end
204
205
 
205
206
  def read(key)
@@ -223,8 +224,8 @@ module Rack::Cache
223
224
  @hash
224
225
  end
225
226
 
226
- def self.resolve(uri)
227
- new
227
+ def self.resolve(uri, options = {})
228
+ new({}, options)
228
229
  end
229
230
  end
230
231
 
@@ -14,12 +14,12 @@ module Rack::Cache
14
14
  @entitystores = {}
15
15
  end
16
16
 
17
- def resolve_metastore_uri(uri)
18
- @metastores[uri.to_s] ||= create_store(MetaStore, uri)
17
+ def resolve_metastore_uri(uri, options = {})
18
+ @metastores[uri.to_s] ||= create_store(MetaStore, uri, options)
19
19
  end
20
20
 
21
- def resolve_entitystore_uri(uri)
22
- @entitystores[uri.to_s] ||= create_store(EntityStore, uri)
21
+ def resolve_entitystore_uri(uri, options = {})
22
+ @entitystores[uri.to_s] ||= create_store(EntityStore, uri, options)
23
23
  end
24
24
 
25
25
  def clear
@@ -30,12 +30,13 @@ module Rack::Cache
30
30
 
31
31
  private
32
32
 
33
- def create_store(type, uri)
33
+ def create_store(type, uri, options = {})
34
34
  if uri.respond_to?(:scheme) || uri.respond_to?(:to_str)
35
35
  uri = URI.parse(uri) unless uri.respond_to?(:scheme)
36
36
  if type.const_defined?(uri.scheme.upcase)
37
37
  klass = type.const_get(uri.scheme.upcase)
38
- klass.resolve(uri)
38
+ return klass.resolve(uri) if klass.method(:resolve).arity == 1
39
+ klass.resolve(uri, options)
39
40
  else
40
41
  fail "Unknown storage provider: #{uri.to_s}"
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -156,15 +156,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 2.0.0
159
+ version: 2.3.0
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.6
166
+ rubygems_version: 3.0.3
168
167
  signing_key:
169
168
  specification_version: 4
170
169
  summary: HTTP Caching for Rack