rack-cache 0.2.0 → 0.3.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.
Potentially problematic release.
This version of rack-cache might be problematic. Click here for more details.
- data/CHANGES +58 -0
- data/README +14 -9
- data/Rakefile +11 -5
- data/TODO +11 -19
- data/doc/configuration.markdown +9 -1
- data/doc/index.markdown +17 -10
- data/doc/layout.html.erb +1 -0
- data/doc/server.ru +34 -0
- data/lib/rack/cache/config/default.rb +1 -2
- data/lib/rack/cache/core.rb +37 -9
- data/lib/rack/cache/entitystore.rb +29 -6
- data/lib/rack/cache/headers.rb +118 -30
- data/lib/rack/cache/metastore.rb +22 -39
- data/lib/rack/cache/options.rb +11 -1
- data/lib/rack/cache/response.rb +2 -2
- data/rack-cache.gemspec +5 -4
- data/test/cache_test.rb +3 -3
- data/test/context_test.rb +255 -75
- data/test/core_test.rb +8 -8
- data/test/entitystore_test.rb +23 -11
- data/test/environment_headers_test.rb +10 -12
- data/test/headers_test.rb +106 -23
- data/test/metastore_test.rb +28 -18
- data/test/options_test.rb +13 -10
- data/test/spec_setup.rb +13 -7
- metadata +8 -4
data/test/options_test.rb
CHANGED
@@ -7,7 +7,10 @@ end
|
|
7
7
|
|
8
8
|
class MockOptions
|
9
9
|
include Rack::Cache::Options
|
10
|
-
|
10
|
+
def initialize
|
11
|
+
@env = nil
|
12
|
+
initialize_options
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
describe 'Rack::Cache::Options' do
|
@@ -16,30 +19,30 @@ describe 'Rack::Cache::Options' do
|
|
16
19
|
describe '#set' do
|
17
20
|
it 'sets a Symbol option as rack-cache.symbol' do
|
18
21
|
@options.set :bar, 'baz'
|
19
|
-
@options.options['rack-cache.bar'].should.
|
22
|
+
@options.options['rack-cache.bar'].should.equal 'baz'
|
20
23
|
end
|
21
24
|
it 'sets a String option as string' do
|
22
25
|
@options.set 'foo.bar', 'bling'
|
23
|
-
@options.options['foo.bar'].should.
|
26
|
+
@options.options['foo.bar'].should.equal 'bling'
|
24
27
|
end
|
25
28
|
it 'sets all key/value pairs when given a Hash' do
|
26
29
|
@options.set :foo => 'bar', :bar => 'baz', 'foo.bar' => 'bling'
|
27
|
-
@options.foo.should.
|
28
|
-
@options.options['rack-cache.bar'].should.
|
29
|
-
@options.options['foo.bar'].should.
|
30
|
+
@options.foo.should.equal 'bar'
|
31
|
+
@options.options['rack-cache.bar'].should.equal 'baz'
|
32
|
+
@options.options['foo.bar'].should.equal 'bling'
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
it 'makes options declared with option_accessor available as attributes' do
|
34
37
|
@options.set :foo, 'bar'
|
35
|
-
@options.foo.should.
|
38
|
+
@options.foo.should.equal 'bar'
|
36
39
|
end
|
37
40
|
|
38
41
|
it 'allows setting multiple options via assignment' do
|
39
42
|
@options.options = { :foo => 'bar', :bar => 'baz', 'foo.bar' => 'bling' }
|
40
|
-
@options.foo.should.
|
41
|
-
@options.options['foo.bar'].should.
|
42
|
-
@options.options['rack-cache.bar'].should.
|
43
|
+
@options.foo.should.equal 'bar'
|
44
|
+
@options.options['foo.bar'].should.equal 'bling'
|
45
|
+
@options.options['rack-cache.bar'].should.equal 'baz'
|
43
46
|
end
|
44
47
|
|
45
48
|
it 'allows the meta store to be configured' do
|
data/test/spec_setup.rb
CHANGED
@@ -16,19 +16,23 @@ ENV['MEMCACHED'] ||= 'localhost:11215'
|
|
16
16
|
$memcached = nil
|
17
17
|
|
18
18
|
def have_memcached?(server=ENV['MEMCACHED'])
|
19
|
-
return
|
19
|
+
return $memcached unless $memcached.nil?
|
20
|
+
v, $VERBOSE = $VERBOSE, nil # silence warnings from memcached
|
20
21
|
require 'memcached'
|
22
|
+
$VERBOSE = v
|
21
23
|
$memcached = Memcached.new(server)
|
22
24
|
$memcached.set('ping', '')
|
23
25
|
true
|
24
26
|
rescue LoadError => boom
|
25
|
-
$memcached =
|
27
|
+
$memcached = false
|
26
28
|
false
|
27
29
|
rescue => boom
|
28
|
-
$memcached =
|
30
|
+
$memcached = false
|
29
31
|
false
|
30
32
|
end
|
31
33
|
|
34
|
+
have_memcached?
|
35
|
+
|
32
36
|
def need_memcached(forwhat)
|
33
37
|
if have_memcached?
|
34
38
|
yield
|
@@ -125,7 +129,7 @@ module CacheContextHelpers
|
|
125
129
|
@caches << @cache
|
126
130
|
@request = Rack::MockRequest.new(@cache)
|
127
131
|
yield @cache if block_given?
|
128
|
-
@response = @request.
|
132
|
+
@response = @request.request(method.to_s.upcase, uri, opts)
|
129
133
|
@responses << @response
|
130
134
|
@response
|
131
135
|
end
|
@@ -134,10 +138,13 @@ module CacheContextHelpers
|
|
134
138
|
request(:get, stem, env, &b)
|
135
139
|
end
|
136
140
|
|
141
|
+
def head(stem, env={}, &b)
|
142
|
+
request(:head, stem, env, &b)
|
143
|
+
end
|
144
|
+
|
137
145
|
def post(*args, &b)
|
138
146
|
request(:post, *args, &b)
|
139
147
|
end
|
140
|
-
|
141
148
|
end
|
142
149
|
|
143
150
|
|
@@ -149,7 +156,7 @@ module TestHelpers
|
|
149
156
|
|
150
157
|
def create_temp_directory
|
151
158
|
@@temp_dir_count += 1
|
152
|
-
path = F.join(Dir.tmpdir, "
|
159
|
+
path = F.join(Dir.tmpdir, "rack-cache-#{$$}-#{@@temp_dir_count}")
|
153
160
|
mkdir_p path
|
154
161
|
if block_given?
|
155
162
|
yield path
|
@@ -186,4 +193,3 @@ class Object
|
|
186
193
|
class_eval { define_method name, &blk }
|
187
194
|
end
|
188
195
|
end
|
189
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-28 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -29,7 +29,10 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
+
- README
|
32
33
|
- COPYING
|
34
|
+
- TODO
|
35
|
+
- CHANGES
|
33
36
|
files:
|
34
37
|
- CHANGES
|
35
38
|
- COPYING
|
@@ -43,6 +46,7 @@ files:
|
|
43
46
|
- doc/layout.html.erb
|
44
47
|
- doc/license.markdown
|
45
48
|
- doc/rack-cache.css
|
49
|
+
- doc/server.ru
|
46
50
|
- doc/storage.markdown
|
47
51
|
- lib/rack/cache.rb
|
48
52
|
- lib/rack/cache/config.rb
|
@@ -75,7 +79,7 @@ files:
|
|
75
79
|
- test/spec_setup.rb
|
76
80
|
- test/storage_test.rb
|
77
81
|
has_rdoc: true
|
78
|
-
homepage: http://
|
82
|
+
homepage: http://tomayko.com/src/rack-cache/
|
79
83
|
post_install_message:
|
80
84
|
rdoc_options:
|
81
85
|
- --line-numbers
|
@@ -101,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
105
|
requirements: []
|
102
106
|
|
103
107
|
rubyforge_project: wink
|
104
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.3.1
|
105
109
|
signing_key:
|
106
110
|
specification_version: 2
|
107
111
|
summary: HTTP Caching for Rack
|