rack-cache 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-cache might be problematic. Click here for more details.

Files changed (44) hide show
  1. data/CHANGES +27 -0
  2. data/COPYING +18 -0
  3. data/README +96 -0
  4. data/Rakefile +144 -0
  5. data/TODO +40 -0
  6. data/doc/configuration.markdown +224 -0
  7. data/doc/events.dot +27 -0
  8. data/doc/faq.markdown +133 -0
  9. data/doc/index.markdown +113 -0
  10. data/doc/layout.html.erb +33 -0
  11. data/doc/license.markdown +24 -0
  12. data/doc/rack-cache.css +362 -0
  13. data/doc/storage.markdown +162 -0
  14. data/lib/rack/cache.rb +51 -0
  15. data/lib/rack/cache/config.rb +65 -0
  16. data/lib/rack/cache/config/busters.rb +16 -0
  17. data/lib/rack/cache/config/default.rb +134 -0
  18. data/lib/rack/cache/config/no-cache.rb +13 -0
  19. data/lib/rack/cache/context.rb +95 -0
  20. data/lib/rack/cache/core.rb +271 -0
  21. data/lib/rack/cache/entitystore.rb +224 -0
  22. data/lib/rack/cache/headers.rb +237 -0
  23. data/lib/rack/cache/metastore.rb +309 -0
  24. data/lib/rack/cache/options.rb +119 -0
  25. data/lib/rack/cache/request.rb +37 -0
  26. data/lib/rack/cache/response.rb +76 -0
  27. data/lib/rack/cache/storage.rb +50 -0
  28. data/lib/rack/utils/environment_headers.rb +78 -0
  29. data/rack-cache.gemspec +74 -0
  30. data/test/cache_test.rb +35 -0
  31. data/test/config_test.rb +66 -0
  32. data/test/context_test.rb +465 -0
  33. data/test/core_test.rb +84 -0
  34. data/test/entitystore_test.rb +176 -0
  35. data/test/environment_headers_test.rb +71 -0
  36. data/test/headers_test.rb +215 -0
  37. data/test/logging_test.rb +45 -0
  38. data/test/metastore_test.rb +210 -0
  39. data/test/options_test.rb +64 -0
  40. data/test/pony.jpg +0 -0
  41. data/test/response_test.rb +37 -0
  42. data/test/spec_setup.rb +189 -0
  43. data/test/storage_test.rb +94 -0
  44. metadata +120 -0
@@ -0,0 +1,94 @@
1
+ require "#{File.dirname(__FILE__)}/spec_setup"
2
+ require 'rack/cache/storage'
3
+
4
+ describe 'Rack::Cache::Storage' do
5
+ before do
6
+ @storage = Rack::Cache::Storage.new
7
+ end
8
+
9
+ it "fails when an unknown URI scheme is provided" do
10
+ lambda { @storage.resolve_metastore_uri('foo:/') }.should.raise
11
+ end
12
+ it "creates a new MetaStore for URI if none exists" do
13
+ @storage.resolve_metastore_uri('heap:/').
14
+ should.be.kind_of Rack::Cache::MetaStore
15
+ end
16
+ it "returns an existing MetaStore instance for URI that exists" do
17
+ store = @storage.resolve_metastore_uri('heap:/')
18
+ @storage.resolve_metastore_uri('heap:/').should.be store
19
+ end
20
+ it "creates a new EntityStore for URI if none exists" do
21
+ @storage.resolve_entitystore_uri('heap:/').
22
+ should.be.kind_of Rack::Cache::EntityStore
23
+ end
24
+ it "returns an existing EntityStore instance for URI that exists" do
25
+ store = @storage.resolve_entitystore_uri('heap:/')
26
+ @storage.resolve_entitystore_uri('heap:/').should.be store
27
+ end
28
+ it "clears all URI -> store mappings with #clear" do
29
+ meta = @storage.resolve_metastore_uri('heap:/')
30
+ entity = @storage.resolve_entitystore_uri('heap:/')
31
+ @storage.clear
32
+ @storage.resolve_metastore_uri('heap:/').should.not.be meta
33
+ @storage.resolve_entitystore_uri('heap:/').should.not.be entity
34
+ end
35
+
36
+ describe 'Heap Store URIs' do
37
+ %w[heap:/ mem:/].each do |uri|
38
+ it "resolves #{uri} meta store URIs" do
39
+ @storage.resolve_metastore_uri(uri).
40
+ should.be.kind_of Rack::Cache::MetaStore
41
+ end
42
+ it "resolves #{uri} entity store URIs" do
43
+ @storage.resolve_entitystore_uri(uri).
44
+ should.be.kind_of Rack::Cache::EntityStore
45
+ end
46
+ end
47
+ end
48
+
49
+ describe 'Disk Store URIs' do
50
+ before do
51
+ @temp_dir = create_temp_directory
52
+ end
53
+ after do
54
+ remove_entry_secure @temp_dir
55
+ @temp_dir = nil
56
+ end
57
+
58
+ %w[file: disk:].each do |uri|
59
+ it "resolves #{uri} meta store URIs" do
60
+ @storage.resolve_metastore_uri(uri + @temp_dir).
61
+ should.be.kind_of Rack::Cache::MetaStore
62
+ end
63
+ it "resolves #{uri} entity store URIs" do
64
+ @storage.resolve_entitystore_uri(uri + @temp_dir).
65
+ should.be.kind_of Rack::Cache::EntityStore
66
+ end
67
+ end
68
+ end
69
+
70
+ if have_memcached?
71
+
72
+ describe 'MemCache Store URIs' do
73
+ %w[memcache: memcached:].each do |scheme|
74
+ it "resolves #{scheme} meta store URIs" do
75
+ uri = scheme + '//' + ENV['MEMCACHED']
76
+ @storage.resolve_metastore_uri(uri).
77
+ should.be.kind_of Rack::Cache::MetaStore
78
+ end
79
+ it "resolves #{scheme} entity store URIs" do
80
+ uri = scheme + '//' + ENV['MEMCACHED']
81
+ @storage.resolve_entitystore_uri(uri).
82
+ should.be.kind_of Rack::Cache::EntityStore
83
+ end
84
+ end
85
+ it 'supports namespaces in memcached: URIs' do
86
+ uri = "memcached://" + ENV['MEMCACHED'] + "/namespace"
87
+ @storage.resolve_metastore_uri(uri).
88
+ should.be.kind_of Rack::Cache::MetaStore
89
+ end
90
+ end
91
+
92
+ end
93
+
94
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Tomayko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-24 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.4"
24
+ version:
25
+ description: HTTP Caching for Rack
26
+ email: r@tomayko.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - COPYING
33
+ files:
34
+ - CHANGES
35
+ - COPYING
36
+ - README
37
+ - Rakefile
38
+ - TODO
39
+ - doc/configuration.markdown
40
+ - doc/events.dot
41
+ - doc/faq.markdown
42
+ - doc/index.markdown
43
+ - doc/layout.html.erb
44
+ - doc/license.markdown
45
+ - doc/rack-cache.css
46
+ - doc/storage.markdown
47
+ - lib/rack/cache.rb
48
+ - lib/rack/cache/config.rb
49
+ - lib/rack/cache/config/busters.rb
50
+ - lib/rack/cache/config/default.rb
51
+ - lib/rack/cache/config/no-cache.rb
52
+ - lib/rack/cache/context.rb
53
+ - lib/rack/cache/core.rb
54
+ - lib/rack/cache/entitystore.rb
55
+ - lib/rack/cache/headers.rb
56
+ - lib/rack/cache/metastore.rb
57
+ - lib/rack/cache/options.rb
58
+ - lib/rack/cache/request.rb
59
+ - lib/rack/cache/response.rb
60
+ - lib/rack/cache/storage.rb
61
+ - lib/rack/utils/environment_headers.rb
62
+ - rack-cache.gemspec
63
+ - test/cache_test.rb
64
+ - test/config_test.rb
65
+ - test/context_test.rb
66
+ - test/core_test.rb
67
+ - test/entitystore_test.rb
68
+ - test/environment_headers_test.rb
69
+ - test/headers_test.rb
70
+ - test/logging_test.rb
71
+ - test/metastore_test.rb
72
+ - test/options_test.rb
73
+ - test/pony.jpg
74
+ - test/response_test.rb
75
+ - test/spec_setup.rb
76
+ - test/storage_test.rb
77
+ has_rdoc: true
78
+ homepage: http://github.com/rtomayko/rack-cache
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --line-numbers
82
+ - --inline-source
83
+ - --title
84
+ - Rack::Cache
85
+ - --main
86
+ - Rack::Cache
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ requirements: []
102
+
103
+ rubyforge_project: wink
104
+ rubygems_version: 1.2.0
105
+ signing_key:
106
+ specification_version: 2
107
+ summary: HTTP Caching for Rack
108
+ test_files:
109
+ - test/cache_test.rb
110
+ - test/config_test.rb
111
+ - test/context_test.rb
112
+ - test/core_test.rb
113
+ - test/entitystore_test.rb
114
+ - test/environment_headers_test.rb
115
+ - test/headers_test.rb
116
+ - test/logging_test.rb
117
+ - test/metastore_test.rb
118
+ - test/options_test.rb
119
+ - test/response_test.rb
120
+ - test/storage_test.rb