background_cache 0.1.3 → 0.1.4
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.
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/{MIT-LICENSE → LICENSE} +1 -1
- data/{README.markdown → README.md} +1 -1
- data/Rakefile +1 -23
- data/background_cache.gemspec +25 -0
- data/bin/background_cache +3 -0
- data/lib/background_cache/config.rb +79 -75
- data/lib/background_cache/controller.rb +21 -7
- data/lib/background_cache/helper.rb +11 -4
- data/lib/background_cache/mem_cache.rb +20 -0
- data/lib/background_cache.rb +37 -14
- data/rails/init.rb +8 -3
- data/spec/background_cache_spec.rb +21 -9
- data/spec/fixtures/rails/app/controllers/application_controller.rb +1 -1
- data/spec/fixtures/rails/config/environment.rb +1 -1
- data/spec/fixtures/rails/lib/background_cache_config.rb +11 -11
- data/spec/spec_helper.rb +8 -6
- metadata +65 -28
- data/require.rb +0 -47
data/.gitignore
ADDED
data/Gemfile
ADDED
data/{MIT-LICENSE → LICENSE}
RENAMED
@@ -61,4 +61,4 @@ Rake task
|
|
61
61
|
|
62
62
|
Add <code>rake background_cache</code> to cron. All cache configurations are busted every time it is run.
|
63
63
|
|
64
|
-
To run a specific group of caches, run <code>rake background\_cache[every\_hour]</code> (as per the example above).
|
64
|
+
To run a specific group of caches, run <code>rake background\_cache[every\_hour]</code> (as per the example above).
|
data/Rakefile
CHANGED
@@ -1,23 +1 @@
|
|
1
|
-
require
|
2
|
-
Require.rakefile!
|
3
|
-
|
4
|
-
# You can delete this after you use it
|
5
|
-
desc "Rename project"
|
6
|
-
task :rename do
|
7
|
-
name = ENV['NAME'] || File.basename(Dir.pwd)
|
8
|
-
begin
|
9
|
-
dir = Dir['**/gem_template*']
|
10
|
-
from = dir.pop
|
11
|
-
if from
|
12
|
-
rb = from.include?('.rb')
|
13
|
-
to = File.dirname(from) + "/#{name}#{'.rb' if rb}"
|
14
|
-
FileUtils.mv(from, to)
|
15
|
-
end
|
16
|
-
end while dir.length > 0
|
17
|
-
Dir["**/*"].each do |path|
|
18
|
-
next if path.include?('Rakefile')
|
19
|
-
if File.file?(path)
|
20
|
-
`sed -i "" 's/gem_template/#{name}/g' #{path}`
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
root = File.expand_path('../', __FILE__)
|
3
|
+
lib = "#{root}/lib"
|
4
|
+
|
5
|
+
$:.unshift lib unless $:.include?(lib)
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "background_cache"
|
9
|
+
s.version = '0.1.4'
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = [ "Winton Welsh" ]
|
12
|
+
s.email = [ "mail@wintoni.us" ]
|
13
|
+
s.homepage = "http://github.com/winton/background_cache"
|
14
|
+
s.summary = %q{Bust caches before your users do}
|
15
|
+
s.description = %q{Bust caches before your users do.}
|
16
|
+
|
17
|
+
s.executables = `cd #{root} && git ls-files bin/*`.split("\n").collect { |f| File.basename(f) }
|
18
|
+
s.files = `cd #{root} && git ls-files`.split("\n")
|
19
|
+
s.require_paths = %w(lib)
|
20
|
+
s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
|
21
|
+
|
22
|
+
s.add_development_dependency "rack-test", "= 0.5.3"
|
23
|
+
s.add_development_dependency "rails", "= 2.3.10"
|
24
|
+
s.add_development_dependency "rspec", "~> 1.0"
|
25
|
+
end
|
@@ -1,113 +1,117 @@
|
|
1
|
-
require 'digest/sha2'
|
2
|
-
|
3
1
|
module BackgroundCache
|
4
2
|
class Config
|
3
|
+
|
5
4
|
class <<self
|
6
|
-
attr_accessor :
|
5
|
+
attr_accessor :current_cache, :group
|
7
6
|
end
|
7
|
+
|
8
8
|
def initialize(&block)
|
9
9
|
@@caches = []
|
10
10
|
self.instance_eval &block
|
11
11
|
end
|
12
|
+
|
12
13
|
def cache(options)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# Store the cache options
|
17
|
-
@@caches.push({
|
18
|
-
:except => options.delete(:except),
|
19
|
-
:group => options.delete(:group),
|
20
|
-
:layout => options.delete(:layout),
|
21
|
-
:only => options.delete(:only),
|
22
|
-
:path => options.delete(:path),
|
23
|
-
:params => options
|
24
|
-
})
|
14
|
+
@options ||= []
|
15
|
+
options = @options.inject({}) { |hash, option| hash.merge(option) }.merge(options)
|
16
|
+
@@caches << self.class.build_cache(options)
|
25
17
|
end
|
18
|
+
|
26
19
|
def except(value, &block)
|
27
|
-
set_option(:except
|
20
|
+
set_option({ :except => value }, &block)
|
28
21
|
end
|
22
|
+
|
29
23
|
def group(value, &block)
|
30
|
-
|
24
|
+
if self.class.group.nil? || value == self.class.group
|
25
|
+
set_option({ :group => value }, &block)
|
26
|
+
end
|
31
27
|
end
|
28
|
+
|
32
29
|
def layout(value, &block)
|
33
|
-
set_option(:layout
|
30
|
+
set_option({ :layout => value }, &block)
|
34
31
|
end
|
32
|
+
|
35
33
|
def only(value, &block)
|
36
|
-
set_option(:only
|
34
|
+
set_option({ :only => value }, &block)
|
37
35
|
end
|
38
|
-
|
39
|
-
|
40
|
-
@options[
|
36
|
+
|
37
|
+
def set_option(hash, &block)
|
38
|
+
@options ||= []
|
39
|
+
@options << hash
|
41
40
|
if block
|
41
|
+
@last_option_index ||= []
|
42
|
+
@last_option_index << (@options.length - 1)
|
42
43
|
yield
|
43
|
-
@
|
44
|
+
@last_option_index.pop
|
45
|
+
if @last_option_index.empty?
|
46
|
+
@options = []
|
47
|
+
else
|
48
|
+
@options = @options[0..@last_option_index.last]
|
49
|
+
end
|
44
50
|
end
|
45
51
|
self
|
46
52
|
end
|
47
|
-
|
48
|
-
def self.
|
49
|
-
|
53
|
+
|
54
|
+
def self.build_cache(options)
|
55
|
+
{
|
56
|
+
:except => options.delete(:except),
|
57
|
+
:group => options.delete(:group),
|
58
|
+
:layout => options.delete(:layout),
|
59
|
+
:only => options.delete(:only),
|
60
|
+
:path => options.delete(:path),
|
61
|
+
:params => options
|
62
|
+
}
|
50
63
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
cache =
|
55
|
-
|
56
|
-
|
57
|
-
|
64
|
+
|
65
|
+
# Does controller and fragment match current cache?
|
66
|
+
def self.match?(fragment={})
|
67
|
+
cache = self.current_cache
|
68
|
+
cache &&
|
69
|
+
# Basic params match (action, controller, etc)
|
70
|
+
(
|
71
|
+
# No fragment specified
|
72
|
+
fragment.empty? ||
|
73
|
+
(
|
74
|
+
(
|
75
|
+
# :only not defined
|
76
|
+
!cache[:only] ||
|
77
|
+
# :only matches fragment
|
78
|
+
cache[:only] == fragment ||
|
58
79
|
(
|
59
|
-
|
60
|
-
|
61
|
-
|
80
|
+
# :only is an array
|
81
|
+
cache[:only].respond_to?(:compact) &&
|
82
|
+
# :only includes matching fragment
|
83
|
+
cache[:only].include?(fragment)
|
84
|
+
)
|
85
|
+
) &&
|
86
|
+
(
|
87
|
+
# :except not defined
|
88
|
+
!cache[:except] ||
|
89
|
+
# :except not explicitly named
|
90
|
+
cache[:except] != fragment ||
|
62
91
|
(
|
63
|
-
#
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# :only not defined
|
68
|
-
!item[:only] ||
|
69
|
-
# :only matches fragment
|
70
|
-
item[:only] == fragment ||
|
71
|
-
(
|
72
|
-
# :only is an array
|
73
|
-
item[:only].respond_to?(:index) &&
|
74
|
-
# :only includes matching fragment
|
75
|
-
item[:only].include?(fragment)
|
76
|
-
)
|
77
|
-
) &&
|
78
|
-
(
|
79
|
-
# :except not defined
|
80
|
-
!item[:except] ||
|
81
|
-
# :except not explicitly named
|
82
|
-
item[:except] != fragment ||
|
83
|
-
(
|
84
|
-
# :except is an array
|
85
|
-
item[:except].respond_to?(:index) &&
|
86
|
-
# :except does not include matching fragment
|
87
|
-
!item[:except].include?(fragment)
|
88
|
-
)
|
89
|
-
)
|
90
|
-
)
|
92
|
+
# :except is an array
|
93
|
+
cache[:except].respond_to?(:compact) &&
|
94
|
+
# :except does not include matching fragment
|
95
|
+
!cache[:except].include?(fragment)
|
91
96
|
)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
cache = { :path => path, :layout => false }
|
96
|
-
end
|
97
|
-
cache
|
97
|
+
)
|
98
|
+
)
|
99
|
+
)
|
98
100
|
end
|
101
|
+
|
99
102
|
def self.caches
|
100
103
|
defined?(@@caches) ? @@caches : []
|
101
104
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def self.load!
|
105
|
+
|
106
|
+
def self.load!(group=nil)
|
107
|
+
self.group = group
|
106
108
|
load RAILS_ROOT + "/lib/background_cache_config.rb"
|
109
|
+
self.group = nil
|
107
110
|
end
|
111
|
+
|
108
112
|
def self.unload!
|
109
113
|
@@caches = []
|
110
|
-
self.
|
114
|
+
self.current_cache = nil
|
111
115
|
end
|
112
116
|
end
|
113
117
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module BackgroundCache
|
2
2
|
module Controller
|
3
|
+
|
3
4
|
def self.included(base)
|
4
5
|
base.alias_method_chain :read_fragment, :background_cache
|
6
|
+
base.alias_method_chain :render, :background_cache
|
5
7
|
base.around_filter BackgroundCacheFilter.new
|
6
8
|
end
|
7
9
|
|
8
10
|
private
|
9
11
|
|
10
12
|
def read_fragment_with_background_cache(key, options=nil)
|
11
|
-
|
12
|
-
if cache
|
13
|
+
if BackgroundCache.active? && BackgroundCache.match?(key)
|
13
14
|
RAILS_DEFAULT_LOGGER.info "Cached fragment busted (read_fragment method): #{key}"
|
14
15
|
nil
|
15
16
|
else
|
@@ -17,20 +18,33 @@ module BackgroundCache
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
def render_with_background_cache(options = nil, extra_options = {}, &block)
|
22
|
+
if BackgroundCache.active? && BackgroundCache::Config.current_cache[:layout] == false
|
23
|
+
[ options, extra_options ].each do |opts|
|
24
|
+
if opts.respond_to?(:keys) && (opts[:layout] || opts['layout'])
|
25
|
+
opts[opts[:layout] ? :layout : 'layout'] = false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
render_without_background_cache(options, extra_options, &block)
|
30
|
+
end
|
31
|
+
|
20
32
|
class BackgroundCacheFilter
|
33
|
+
|
21
34
|
def before(controller)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if cache && cache[:layout] == false
|
35
|
+
cache = BackgroundCache::Config.current_cache
|
36
|
+
if cache
|
37
|
+
if cache[:layout] == false
|
26
38
|
@background_cache_layout = controller.active_layout
|
27
39
|
controller.class.layout(false)
|
40
|
+
else
|
41
|
+
@background_cache_layout = nil
|
28
42
|
end
|
29
43
|
end
|
30
44
|
true
|
31
45
|
end
|
46
|
+
|
32
47
|
def after(controller)
|
33
|
-
# Restore layout
|
34
48
|
if @background_cache_layout
|
35
49
|
controller.class.layout(@background_cache_layout)
|
36
50
|
end
|
@@ -1,23 +1,30 @@
|
|
1
1
|
module BackgroundCache
|
2
2
|
module Helper
|
3
|
+
|
3
4
|
def self.included(base)
|
4
5
|
base.alias_method_chain :cache, :background_cache
|
5
6
|
end
|
7
|
+
|
6
8
|
def cache_with_background_cache(name = {}, options = nil, &block)
|
7
9
|
# http://railsapi.com/doc/rails-v2.3.8/classes/ActionView/Helpers/CacheHelper.html
|
8
10
|
# ActionController::Caching::Fragments#fragment_for (undocumented)
|
9
11
|
# actionpack/lib/action_controller/caching/fragments.rb
|
10
12
|
if @controller.perform_caching
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
cache = @controller.read_fragment(name, options)
|
14
|
+
match = (
|
15
|
+
BackgroundCache.active? &&
|
16
|
+
BackgroundCache.match?(name)
|
17
|
+
)
|
18
|
+
if !cache || match
|
14
19
|
pos = output_buffer.length
|
15
20
|
block.call
|
16
21
|
output = [
|
17
|
-
"<!-- #{name.inspect} cached #{Time.now.strftime("%m/%d/%Y at %I:%M %p")} -->",
|
22
|
+
"<!-- #{name.inspect}#{' background' if match} cached #{Time.now.strftime("%m/%d/%Y at %I:%M %p")} -->",
|
18
23
|
output_buffer[pos..-1]
|
19
24
|
].join("\n")
|
20
25
|
@controller.write_fragment(name, output, options)
|
26
|
+
else
|
27
|
+
output_buffer.concat(cache)
|
21
28
|
end
|
22
29
|
else
|
23
30
|
block.call
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BackgroundCache
|
2
|
+
module Memcache
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.alias_method_chain :get, :background_cache
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_with_background_cache(key, raw=false)
|
9
|
+
match = (
|
10
|
+
BackgroundCache.active? &&
|
11
|
+
BackgroundCache.match?(key)
|
12
|
+
)
|
13
|
+
if match
|
14
|
+
nil
|
15
|
+
else
|
16
|
+
get_without_background_cache(key, raw)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/background_cache.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
gem 'rack-test', '=0.5.3'
|
2
|
+
|
3
|
+
require 'digest/sha2'
|
4
|
+
require 'rack/test'
|
5
|
+
|
6
|
+
$:.unshift File.dirname(__FILE__)
|
7
|
+
|
8
|
+
require 'background_cache/config'
|
9
|
+
require 'background_cache/controller'
|
10
|
+
require 'background_cache/helper'
|
11
|
+
require 'background_cache/mem_cache'
|
3
12
|
|
4
13
|
module BackgroundCache
|
5
14
|
|
@@ -11,34 +20,48 @@ module BackgroundCache
|
|
11
20
|
end
|
12
21
|
end
|
13
22
|
|
23
|
+
def self.active?
|
24
|
+
BackgroundCache::Config.current_cache
|
25
|
+
end
|
26
|
+
|
14
27
|
def self.cache!(group=nil)
|
15
28
|
instance = self.boot
|
29
|
+
BackgroundCache::Config.load!(group)
|
16
30
|
caches = BackgroundCache::Config.caches
|
17
31
|
caches.each do |cache|
|
18
32
|
next if group && cache[:group] != group
|
19
|
-
|
20
|
-
puts "(#{cache[:group]}) #{url}"
|
21
|
-
instance.get(url)
|
33
|
+
self.manual(cache, instance)
|
22
34
|
end
|
23
35
|
end
|
24
|
-
|
25
|
-
def self.manual(
|
26
|
-
instance
|
27
|
-
|
28
|
-
|
36
|
+
|
37
|
+
def self.manual(cache, instance=nil)
|
38
|
+
unless instance
|
39
|
+
instance = self.boot
|
40
|
+
end
|
41
|
+
BackgroundCache::Config.current_cache = cache
|
42
|
+
url = cache[:path] || instance.url_for(cache[:params].merge(:only_path => true))
|
43
|
+
puts "(#{cache[:group]}) #{url}"
|
29
44
|
instance.get(url)
|
45
|
+
BackgroundCache::Config.current_cache = nil
|
30
46
|
url
|
31
47
|
end
|
32
48
|
|
49
|
+
def self.match?(fragment={})
|
50
|
+
BackgroundCache::Config.match?(fragment)
|
51
|
+
end
|
52
|
+
|
33
53
|
private
|
34
|
-
|
54
|
+
|
35
55
|
def self.boot
|
36
56
|
instance = AppInstance.new
|
37
|
-
BackgroundCache::Config.load!
|
38
57
|
instance
|
39
58
|
end
|
40
59
|
end
|
41
60
|
|
42
|
-
def BackgroundCache(
|
43
|
-
BackgroundCache.manual(
|
61
|
+
def BackgroundCache(path, layout=false)
|
62
|
+
BackgroundCache.manual(
|
63
|
+
BackgroundCache::Config.build_cache(
|
64
|
+
path.respond_to?(:keys) ? path : { :path => path, :layout => layout }
|
65
|
+
)
|
66
|
+
)
|
44
67
|
end
|
data/rails/init.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
begin
|
2
|
+
require 'memcache'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
require File.expand_path('../../lib/background_cache.rb', __FILE__)
|
3
7
|
|
4
8
|
ActionController::Base.send(:include, BackgroundCache::Controller)
|
5
|
-
ActionView::Helpers::CacheHelper.send(:include, BackgroundCache::Helper)
|
9
|
+
ActionView::Helpers::CacheHelper.send(:include, BackgroundCache::Helper)
|
10
|
+
::MemCache.send(:include, BackgroundCache::Memcache) if defined?(::MemCache)
|
@@ -18,16 +18,12 @@ describe BackgroundCache do
|
|
18
18
|
BackgroundCache::Config.should_receive(:load!)
|
19
19
|
BackgroundCache.cache!
|
20
20
|
end
|
21
|
-
|
22
|
-
it "should call from_controller when cached request happens" do
|
23
|
-
BackgroundCache.cache!
|
24
|
-
BackgroundCache::Config.should_receive(:from_controller)
|
25
|
-
get('/')
|
26
|
-
end
|
27
21
|
|
28
22
|
it "should alias read_fragment and return null when it is called on matching cache" do
|
29
23
|
BackgroundCache.cache!
|
30
|
-
|
24
|
+
BackgroundCache::Config.current_cache = BackgroundCache::Config.caches.detect do |cache|
|
25
|
+
cache[:params][:action] == 'test_3'
|
26
|
+
end
|
31
27
|
cache_write('test_3', 'bust me')
|
32
28
|
get('/t3')
|
33
29
|
last_response.body.should == 'nil'
|
@@ -74,12 +70,12 @@ describe BackgroundCache do
|
|
74
70
|
|
75
71
|
it "should bust the cache (manual override)" do
|
76
72
|
cache_write('test', 'bust me')
|
77
|
-
BackgroundCache
|
73
|
+
BackgroundCache('/b')
|
78
74
|
cache_read('test').should == 'test'
|
79
75
|
end
|
80
76
|
|
81
77
|
it "should not render the layout" do
|
82
|
-
BackgroundCache
|
78
|
+
BackgroundCache('/b')
|
83
79
|
cache_read('layout_test_1').should == nil
|
84
80
|
end
|
85
81
|
end
|
@@ -111,5 +107,21 @@ describe BackgroundCache do
|
|
111
107
|
cache_read('layout_test_2').should == nil
|
112
108
|
end
|
113
109
|
end
|
110
|
+
|
111
|
+
describe :test_3 do
|
112
|
+
|
113
|
+
it "should be caching normally" do
|
114
|
+
get('/t3')
|
115
|
+
cache_read('layout_test_3').should == '1'
|
116
|
+
cache_write('layout_test_3', 'bust me')
|
117
|
+
get('/t3')
|
118
|
+
cache_read('layout_test_3').should == 'bust me'
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should not render the layout" do
|
122
|
+
BackgroundCache.cache!
|
123
|
+
cache_read('layout_test_3').should == nil
|
124
|
+
end
|
125
|
+
end
|
114
126
|
end
|
115
127
|
end
|
@@ -9,6 +9,6 @@ class ApplicationController < ActionController::Base
|
|
9
9
|
# filter_parameter_logging :password
|
10
10
|
|
11
11
|
def test_3
|
12
|
-
render :text => read_fragment('test_3').inspect, :layout =>
|
12
|
+
render :text => read_fragment('test_3').inspect, :layout => 'application'
|
13
13
|
end
|
14
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file
|
2
2
|
|
3
3
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
4
|
-
RAILS_GEM_VERSION = '2.3.
|
4
|
+
RAILS_GEM_VERSION = '2.3.10' unless defined? RAILS_GEM_VERSION
|
5
5
|
|
6
6
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
7
7
|
require File.join(File.dirname(__FILE__), 'boot')
|
@@ -1,15 +1,15 @@
|
|
1
|
-
BackgroundCache::Config.new do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
BackgroundCache::Config.new do
|
2
|
+
cache(:path => '/')
|
3
|
+
layout(false) do
|
4
|
+
only('test_2') do
|
5
|
+
cache(
|
6
|
+
:controller => 'application',
|
7
|
+
:action => 'test_2'
|
8
|
+
)
|
9
|
+
end
|
10
|
+
cache(
|
7
11
|
:controller => 'application',
|
8
|
-
:action => '
|
12
|
+
:action => 'test_3'
|
9
13
|
)
|
10
14
|
end
|
11
|
-
config.cache(
|
12
|
-
:controller => 'application',
|
13
|
-
:action => 'test_3'
|
14
|
-
)
|
15
15
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
require "pp"
|
2
|
+
require "bundler"
|
2
3
|
|
3
|
-
require
|
4
|
-
Require.spec_helper!
|
4
|
+
Bundler.require(:development)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
COMMENT_REGEX = /<!-- .+ cached .+ -->\n/
|
7
|
+
RAILS_ENV = 'production'
|
8
|
+
|
9
|
+
require 'spec/fixtures/rails/config/environment'
|
8
10
|
|
9
|
-
|
11
|
+
$root = File.expand_path('../../', __FILE__)
|
10
12
|
|
11
13
|
def cache_read(key)
|
12
14
|
value = ::ActionController::Base.cache_store.read('views/' + key)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: background_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-10-20 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rack-test
|
@@ -32,43 +31,63 @@ dependencies:
|
|
32
31
|
- 5
|
33
32
|
- 3
|
34
33
|
version: 0.5.3
|
35
|
-
type: :
|
34
|
+
type: :development
|
36
35
|
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
37
|
+
name: rails
|
39
38
|
prerelease: false
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - "="
|
44
43
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
44
|
+
hash: 23
|
46
45
|
segments:
|
47
|
-
- 0
|
48
46
|
- 2
|
49
|
-
-
|
50
|
-
|
51
|
-
|
47
|
+
- 3
|
48
|
+
- 10
|
49
|
+
version: 2.3.10
|
50
|
+
type: :development
|
52
51
|
version_requirements: *id002
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rspec
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 15
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 0
|
64
|
+
version: "1.0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Bust caches before your users do.
|
68
|
+
email:
|
69
|
+
- mail@wintoni.us
|
70
|
+
executables:
|
71
|
+
- background_cache
|
57
72
|
extensions: []
|
58
73
|
|
59
|
-
extra_rdoc_files:
|
60
|
-
|
74
|
+
extra_rdoc_files: []
|
75
|
+
|
61
76
|
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- background_cache.gemspec
|
83
|
+
- bin/background_cache
|
62
84
|
- init.rb
|
85
|
+
- lib/background_cache.rb
|
63
86
|
- lib/background_cache/config.rb
|
64
87
|
- lib/background_cache/controller.rb
|
65
88
|
- lib/background_cache/helper.rb
|
66
|
-
- lib/background_cache.rb
|
67
|
-
- MIT-LICENSE
|
89
|
+
- lib/background_cache/mem_cache.rb
|
68
90
|
- rails/init.rb
|
69
|
-
- Rakefile
|
70
|
-
- README.markdown
|
71
|
-
- require.rb
|
72
91
|
- spec/background_cache_spec.rb
|
73
92
|
- spec/fixtures/rails/app/controllers/application_controller.rb
|
74
93
|
- spec/fixtures/rails/app/helpers/application_helper.rb
|
@@ -90,7 +109,6 @@ files:
|
|
90
109
|
- spec/fixtures/rails/lib/background_cache_config.rb
|
91
110
|
- spec/spec_helper.rb
|
92
111
|
- tasks/background_cache.rake
|
93
|
-
has_rdoc: true
|
94
112
|
homepage: http://github.com/winton/background_cache
|
95
113
|
licenses: []
|
96
114
|
|
@@ -120,9 +138,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
138
|
requirements: []
|
121
139
|
|
122
140
|
rubyforge_project:
|
123
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.8.10
|
124
142
|
signing_key:
|
125
143
|
specification_version: 3
|
126
144
|
summary: Bust caches before your users do
|
127
|
-
test_files:
|
128
|
-
|
145
|
+
test_files:
|
146
|
+
- spec/background_cache_spec.rb
|
147
|
+
- spec/fixtures/rails/app/controllers/application_controller.rb
|
148
|
+
- spec/fixtures/rails/app/helpers/application_helper.rb
|
149
|
+
- spec/fixtures/rails/app/views/application/test_1.html.erb
|
150
|
+
- spec/fixtures/rails/app/views/application/test_2.html.erb
|
151
|
+
- spec/fixtures/rails/app/views/layouts/application.html.erb
|
152
|
+
- spec/fixtures/rails/config/boot.rb
|
153
|
+
- spec/fixtures/rails/config/environment.rb
|
154
|
+
- spec/fixtures/rails/config/environments/development.rb
|
155
|
+
- spec/fixtures/rails/config/environments/production.rb
|
156
|
+
- spec/fixtures/rails/config/environments/test.rb
|
157
|
+
- spec/fixtures/rails/config/initializers/backtrace_silencers.rb
|
158
|
+
- spec/fixtures/rails/config/initializers/inflections.rb
|
159
|
+
- spec/fixtures/rails/config/initializers/mime_types.rb
|
160
|
+
- spec/fixtures/rails/config/initializers/new_rails_defaults.rb
|
161
|
+
- spec/fixtures/rails/config/initializers/session_store.rb
|
162
|
+
- spec/fixtures/rails/config/locales/en.yml
|
163
|
+
- spec/fixtures/rails/config/routes.rb
|
164
|
+
- spec/fixtures/rails/lib/background_cache_config.rb
|
165
|
+
- spec/spec_helper.rb
|
data/require.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem 'require'
|
3
|
-
require 'require'
|
4
|
-
|
5
|
-
Require do
|
6
|
-
gem :require, '=0.2.7'
|
7
|
-
gem(:'rack-test', '=0.5.3') { require 'rack/test' }
|
8
|
-
gem(:rake, '=0.8.7') { require 'rake' }
|
9
|
-
gem :rspec, '=1.3.0'
|
10
|
-
|
11
|
-
gemspec do
|
12
|
-
author 'Winton Welsh'
|
13
|
-
dependencies do
|
14
|
-
gem :'rack-test'
|
15
|
-
gem :require
|
16
|
-
end
|
17
|
-
email 'mail@wintoni.us'
|
18
|
-
name 'background_cache'
|
19
|
-
homepage "http://github.com/winton/#{name}"
|
20
|
-
summary "Bust caches before your users do"
|
21
|
-
version '0.1.3'
|
22
|
-
end
|
23
|
-
|
24
|
-
bin { require 'lib/background_cache' }
|
25
|
-
|
26
|
-
lib do
|
27
|
-
gem :'rack-test'
|
28
|
-
require 'lib/background_cache/config'
|
29
|
-
require 'lib/background_cache/controller'
|
30
|
-
require 'lib/background_cache/helper'
|
31
|
-
end
|
32
|
-
|
33
|
-
rails_init { require 'lib/background_cache' }
|
34
|
-
|
35
|
-
rakefile do
|
36
|
-
gem(:rake) { require 'rake/gempackagetask' }
|
37
|
-
gem(:rspec) { require 'spec/rake/spectask' }
|
38
|
-
require 'require/tasks'
|
39
|
-
end
|
40
|
-
|
41
|
-
spec_helper do
|
42
|
-
gem :'rack-test'
|
43
|
-
require 'require/spec_helper'
|
44
|
-
require 'pp'
|
45
|
-
require 'spec/fixtures/rails/config/environment'
|
46
|
-
end
|
47
|
-
end
|