merb-cache 1.0.15 → 1.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +55 -62
- data/lib/merb-cache/merb_ext/controller.rb +1 -1
- data/lib/merb-cache/stores/fundamental/memcached_store.rb +2 -1
- data/lib/merb-cache/stores/strategy/abstract_strategy_store.rb +17 -17
- data/lib/merb-cache/stores/strategy/gzip_store.rb +2 -2
- data/lib/merb-cache/version.rb +5 -0
- data/lib/merb-cache.rb +7 -5
- data/spec/merb-cache/cache_request_spec.rb +1 -1
- data/spec/merb-cache/cache_spec.rb +1 -1
- data/spec/merb-cache/core_ext/enumerable_spec.rb +1 -1
- data/spec/merb-cache/core_ext/hash_spec.rb +1 -1
- data/spec/merb-cache/merb_ext/controller_spec.rb +1 -1
- data/spec/merb-cache/stores/fundamental/abstract_store_spec.rb +1 -1
- data/spec/merb-cache/stores/fundamental/file_store_spec.rb +2 -3
- data/spec/merb-cache/stores/fundamental/memcached_store_spec.rb +2 -2
- data/spec/merb-cache/stores/strategy/abstract_strategy_store_spec.rb +2 -2
- data/spec/merb-cache/stores/strategy/action_store_spec.rb +2 -2
- data/spec/merb-cache/stores/strategy/adhoc_store_spec.rb +2 -2
- data/spec/merb-cache/stores/strategy/gzip_store_spec.rb +9 -3
- data/spec/merb-cache/stores/strategy/page_store_spec.rb +2 -2
- data/spec/merb-cache/stores/strategy/sha1_store_spec.rb +2 -2
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +16 -11
- metadata +24 -12
data/Rakefile
CHANGED
@@ -1,80 +1,73 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
##############################################################################
|
6
|
-
RUBY_FORGE_PROJECT = "merb"
|
7
|
-
PROJECT_URL = "http://merbivore.com"
|
8
|
-
PROJECT_SUMMARY = "Merb plugin that provides caching (page, action, fragment, object)"
|
9
|
-
PROJECT_DESCRIPTION = PROJECT_SUMMARY
|
10
|
-
|
11
|
-
GEM_AUTHOR = "Ben Burkert"
|
12
|
-
GEM_EMAIL = "ben@benburkert.com"
|
13
|
-
|
14
|
-
GEM_NAME = "merb-cache"
|
15
|
-
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
16
|
-
GEM_VERSION = Merb::VERSION + PKG_BUILD
|
17
|
-
|
18
|
-
RELEASE_NAME = "REL #{GEM_VERSION}"
|
19
|
-
|
20
|
-
require "extlib/tasks/release"
|
21
|
-
|
22
|
-
spec = Gem::Specification.new do |s|
|
23
|
-
s.rubyforge_project = RUBY_FORGE_PROJECT
|
24
|
-
s.name = GEM_NAME
|
25
|
-
s.version = GEM_VERSION
|
26
|
-
s.platform = Gem::Platform::RUBY
|
27
|
-
s.has_rdoc = true
|
28
|
-
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
29
|
-
s.summary = PROJECT_SUMMARY
|
30
|
-
s.description = PROJECT_DESCRIPTION
|
31
|
-
s.author = GEM_AUTHOR
|
32
|
-
s.email = GEM_EMAIL
|
33
|
-
s.homepage = PROJECT_URL
|
34
|
-
s.add_dependency('merb-core', "~> #{Merb::VERSION}")
|
35
|
-
s.require_path = 'lib'
|
36
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
37
|
-
end
|
4
|
+
# Assume a typical dev checkout to fetch the current merb-core version
|
5
|
+
require File.expand_path('../../merb-core/lib/merb-core/version', __FILE__)
|
38
6
|
|
39
|
-
|
40
|
-
|
41
|
-
|
7
|
+
# Load this library's version information
|
8
|
+
require File.expand_path('../lib/merb-cache/version', __FILE__)
|
9
|
+
|
10
|
+
begin
|
11
|
+
|
12
|
+
gem 'jeweler', '~> 1.4'
|
13
|
+
require 'jeweler'
|
14
|
+
|
15
|
+
Jeweler::Tasks.new do |gemspec|
|
16
|
+
|
17
|
+
gemspec.version = Merb::Cache::VERSION
|
18
|
+
|
19
|
+
gemspec.name = "merb-cache"
|
20
|
+
gemspec.description = "Merb plugin for supporting assets"
|
21
|
+
gemspec.summary = "Merb plugin that provides caching (page, action, fragment, object)"
|
22
|
+
|
23
|
+
gemspec.authors = [ "Ben Burkert" ]
|
24
|
+
gemspec.email = "ben@benburkert.com"
|
25
|
+
gemspec.homepage = "http://merbivore.com/"
|
26
|
+
|
27
|
+
gemspec.files = %w(LICENSE Rakefile README TODO) + Dir['{lib,spec}/**/*']
|
42
28
|
|
43
|
-
|
44
|
-
|
45
|
-
|
29
|
+
# Runtime dependencies
|
30
|
+
gemspec.add_dependency 'merb-core', "~> #{Merb::VERSION}"
|
31
|
+
|
32
|
+
# Development dependencies
|
33
|
+
gemspec.add_development_dependency 'rspec', '>= 1.2.9'
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
Jeweler::GemcutterTasks.new
|
38
|
+
|
39
|
+
rescue LoadError
|
40
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
46
41
|
end
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
require 'spec/rake/spectask'
|
44
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
45
|
+
spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
46
|
+
spec.libs << 'lib' << 'spec'
|
47
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
51
48
|
end
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
50
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
51
|
+
spec.libs << 'lib' << 'spec'
|
52
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
53
|
+
spec.rcov = true
|
58
54
|
end
|
59
55
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
56
|
+
task :default => :spec
|
57
|
+
|
58
|
+
require 'rake/rdoctask'
|
59
|
+
Rake::RDocTask.new do |rdoc|
|
60
|
+
rdoc.rdoc_dir = 'rdoc'
|
61
|
+
rdoc.title = "test_gem #{Merb::Cache::VERSION}"
|
62
|
+
rdoc.rdoc_files.include('README*')
|
63
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
70
64
|
end
|
71
65
|
|
72
|
-
desc 'Default: run spec examples'
|
73
|
-
task :default => 'spec'
|
74
66
|
|
75
67
|
##############################################################################
|
76
68
|
# memcached
|
77
69
|
##############################################################################
|
70
|
+
|
78
71
|
MEMCACHED_PORTS = 43042..43043
|
79
72
|
|
80
73
|
namespace :memcached do
|
@@ -89,8 +89,9 @@ module Merb::Cache
|
|
89
89
|
#
|
90
90
|
# Use :buffer_requests option to use bufferring,
|
91
91
|
# :no_block to use non-blocking async I/O.
|
92
|
+
# :support_cas to support CAS
|
92
93
|
def connect(config = {})
|
93
|
-
@memcached = ::Memcached.new(@servers, config.only(:buffer_requests, :no_block).merge(:namespace => @namespace))
|
94
|
+
@memcached = ::Memcached.new(@servers, config.only(:buffer_requests, :no_block, :support_cas).merge(:namespace => @namespace))
|
94
95
|
end
|
95
96
|
|
96
97
|
# Returns cache key calculated from base key
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# -*- coding:
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
module Merb::Cache
|
3
3
|
# A strategy store wraps one or
|
4
4
|
# more fundamental stores, acting as a middle man between caching
|
@@ -35,29 +35,29 @@ module Merb::Cache
|
|
35
35
|
class AbstractStrategyStore < AbstractStore
|
36
36
|
# START: interface for creating strategy stores. This should/might change.
|
37
37
|
def self.contextualize(*stores)
|
38
|
-
|
39
|
-
|
38
|
+
Class.new(self) do
|
39
|
+
cattr_accessor :contextualized_stores
|
40
40
|
|
41
|
-
|
42
|
-
end
|
41
|
+
self.contextualized_stores = stores
|
43
42
|
end
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
class << self
|
46
|
+
alias_method :[], :contextualize
|
47
|
+
end
|
48
48
|
|
49
|
-
|
49
|
+
attr_accessor :stores
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
51
|
+
def initialize(config = {})
|
52
|
+
@stores = contextualized_stores.map do |cs|
|
53
|
+
case cs
|
54
|
+
when Symbol
|
55
|
+
Merb::Cache[cs]
|
56
|
+
when Class
|
57
|
+
cs.new(config)
|
59
58
|
end
|
60
59
|
end
|
60
|
+
end
|
61
61
|
|
62
62
|
# END: interface for creating strategy stores.
|
63
63
|
|
@@ -8,7 +8,7 @@ module Merb::Cache
|
|
8
8
|
# large pages.
|
9
9
|
class GzipStore < AbstractStrategyStore
|
10
10
|
def writable?(key, parameters = {}, conditions = {})
|
11
|
-
|
11
|
+
@stores.any? {|c| c.writable?(key, parameters, conditions)}
|
12
12
|
end
|
13
13
|
|
14
14
|
def read(key, parameters = {})
|
@@ -29,7 +29,7 @@ module Merb::Cache
|
|
29
29
|
|
30
30
|
def fetch(key, parameters = {}, conditions = {}, &blk)
|
31
31
|
wrapper_blk = lambda { compress(blk.call) }
|
32
|
-
|
32
|
+
read(key, parameters) || decompress(@stores.capture_first {|s| s.fetch(key, parameters, conditions, &wrapper_blk)})
|
33
33
|
end
|
34
34
|
|
35
35
|
def exists?(key, parameters = {})
|
data/lib/merb-cache.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# make sure we're running inside Merb
|
2
2
|
if defined?(Merb::Plugins)
|
3
|
-
|
4
|
-
require "merb-cache
|
5
|
-
require "merb-cache
|
6
|
-
require "merb-cache
|
7
|
-
require "merb-cache
|
3
|
+
|
4
|
+
require "merb-cache/cache"
|
5
|
+
require "merb-cache/core_ext/enumerable"
|
6
|
+
require "merb-cache/core_ext/hash"
|
7
|
+
require "merb-cache/merb_ext/controller"
|
8
|
+
require "merb-cache/cache_request"
|
8
9
|
|
9
10
|
class Merb::Controller
|
10
11
|
include Merb::Cache::CacheMixin
|
11
12
|
end
|
13
|
+
|
12
14
|
end
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/abstract_store_spec'
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/fundamental/abstract_store_spec'
|
4
3
|
|
5
4
|
describe Merb::Cache::FileStore do
|
6
5
|
it_should_behave_like 'all stores'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/fundamental/abstract_store_spec'
|
3
3
|
|
4
4
|
|
5
5
|
describe Merb::Cache::AbstractStrategyStore do
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/strategy/abstract_strategy_store_spec'
|
3
3
|
|
4
4
|
describe Merb::Cache::ActionStore do
|
5
5
|
it_should_behave_like 'all strategy stores'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/strategy/abstract_strategy_store_spec'
|
3
3
|
|
4
4
|
describe Merb::Cache::AdhocStore do
|
5
5
|
it_should_behave_like 'all stores'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/strategy/abstract_strategy_store_spec'
|
3
3
|
|
4
4
|
describe Merb::Cache::GzipStore do
|
5
5
|
it_should_behave_like 'all strategy stores'
|
@@ -10,11 +10,17 @@ describe Merb::Cache::GzipStore do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#writable?" do
|
13
|
-
it "should
|
13
|
+
it "should be true whatever the key" do
|
14
14
|
@store.writable?(:foo).should be_true
|
15
15
|
@store.writable?('foo').should be_true
|
16
16
|
@store.writable?(123).should be_true
|
17
17
|
end
|
18
|
+
|
19
|
+
it "should be false if none of the context caches are writable" do
|
20
|
+
@store.stores.each {|s| s.should_receive(:writable?).and_return false}
|
21
|
+
|
22
|
+
@store.writable?(:foo).should be_false
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
describe "#read" do
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/strategy/abstract_strategy_store_spec'
|
3
3
|
|
4
4
|
describe Merb::Cache::PageStore do
|
5
5
|
it_should_behave_like 'all strategy stores'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'merb-cache/stores/strategy/abstract_strategy_store_spec'
|
3
3
|
|
4
4
|
describe Merb::Cache::SHA1Store do
|
5
5
|
it_should_behave_like 'all strategy stores'
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,29 @@
|
|
1
|
-
|
1
|
+
require "rubygems"
|
2
2
|
|
3
|
-
#
|
4
|
-
|
3
|
+
# Use current merb-core sources if running from a typical dev checkout.
|
4
|
+
lib = File.expand_path('../../../merb-core/lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
5
6
|
require 'merb-core'
|
7
|
+
|
8
|
+
# Use current merb-action-args sources if running from a typical dev checkout.
|
9
|
+
lib = File.expand_path('../../../merb-action-args/lib', __FILE__)
|
10
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
6
11
|
require 'merb-action-args'
|
7
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'merb-cache')
|
8
12
|
|
9
|
-
|
13
|
+
# The lib under test
|
14
|
+
require "merb-cache"
|
15
|
+
|
16
|
+
# Satisfies Autotest and anyone else not using the Rake tasks
|
17
|
+
require 'spec'
|
10
18
|
|
11
|
-
Merb.start :environment =>
|
12
|
-
:adapter => "runner",
|
13
|
-
:log_file => File.join(File.dirname(__FILE__), '..', 'log', 'merb_test.log')
|
19
|
+
Merb.start :environment => 'test'
|
14
20
|
|
15
|
-
require "merb-core/test"
|
16
21
|
Spec::Runner.configure do |config|
|
17
|
-
config.include Merb::Test::
|
18
|
-
#config.include Merb::Test::ControllerHelper
|
22
|
+
config.include Merb::Test::RequestHelper
|
19
23
|
config.include Merb::Test::RouteHelper
|
20
24
|
end
|
21
25
|
|
26
|
+
|
22
27
|
class DummyStore < Merb::Cache::AbstractStore
|
23
28
|
cattr_accessor :vault
|
24
29
|
attr_accessor :options
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.1.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Burkert
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-20 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,23 +20,34 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.
|
23
|
+
version: 1.1.0.pre
|
24
24
|
version:
|
25
|
-
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.9
|
34
|
+
version:
|
35
|
+
description: Merb plugin for supporting assets
|
26
36
|
email: ben@benburkert.com
|
27
37
|
executables: []
|
28
38
|
|
29
39
|
extensions: []
|
30
40
|
|
31
41
|
extra_rdoc_files:
|
32
|
-
- README
|
33
42
|
- LICENSE
|
43
|
+
- README
|
34
44
|
- TODO
|
35
45
|
files:
|
36
46
|
- LICENSE
|
37
47
|
- README
|
38
48
|
- Rakefile
|
39
49
|
- TODO
|
50
|
+
- lib/merb-cache.rb
|
40
51
|
- lib/merb-cache/cache.rb
|
41
52
|
- lib/merb-cache/cache_request.rb
|
42
53
|
- lib/merb-cache/core_ext/enumerable.rb
|
@@ -51,7 +62,7 @@ files:
|
|
51
62
|
- lib/merb-cache/stores/strategy/gzip_store.rb
|
52
63
|
- lib/merb-cache/stores/strategy/page_store.rb
|
53
64
|
- lib/merb-cache/stores/strategy/sha1_store.rb
|
54
|
-
- lib/merb-cache.rb
|
65
|
+
- lib/merb-cache/version.rb
|
55
66
|
- spec/merb-cache/cache_request_spec.rb
|
56
67
|
- spec/merb-cache/cache_spec.rb
|
57
68
|
- spec/merb-cache/core_ext/enumerable_spec.rb
|
@@ -66,14 +77,15 @@ files:
|
|
66
77
|
- spec/merb-cache/stores/strategy/gzip_store_spec.rb
|
67
78
|
- spec/merb-cache/stores/strategy/page_store_spec.rb
|
68
79
|
- spec/merb-cache/stores/strategy/sha1_store_spec.rb
|
80
|
+
- spec/spec.opts
|
69
81
|
- spec/spec_helper.rb
|
70
82
|
has_rdoc: true
|
71
|
-
homepage: http://merbivore.com
|
83
|
+
homepage: http://merbivore.com/
|
72
84
|
licenses: []
|
73
85
|
|
74
86
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
87
|
+
rdoc_options:
|
88
|
+
- --charset=UTF-8
|
77
89
|
require_paths:
|
78
90
|
- lib
|
79
91
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -84,13 +96,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
96
|
version:
|
85
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
|
-
- - "
|
99
|
+
- - ">"
|
88
100
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
101
|
+
version: 1.3.1
|
90
102
|
version:
|
91
103
|
requirements: []
|
92
104
|
|
93
|
-
rubyforge_project:
|
105
|
+
rubyforge_project:
|
94
106
|
rubygems_version: 1.3.5
|
95
107
|
signing_key:
|
96
108
|
specification_version: 3
|