radiant-cache_buster-extension 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -0
- data/Rakefile +134 -0
- data/app/controllers/admin/buster_controller.rb +14 -0
- data/app/models/cache_buster.rb +47 -0
- data/app/views/admin/buster/index.html.haml +5 -0
- data/cache_buster_extension.rb +21 -0
- data/config/routes.rb +10 -0
- data/db/migrate/001_create_cache_buster.rb +12 -0
- data/db/migrate/002_create_inital_cache_buster.rb +10 -0
- data/lib/cache_buster_tags.rb +18 -0
- data/lib/radiant-cache_buster-extension.rb +8 -0
- data/lib/tasks/cache_buster_extension_tasks.rake +17 -0
- data/radiant-cache_buster-extension.gemspec +25 -0
- data/spec/ci/before_script +53 -0
- data/spec/ci/script +25 -0
- data/spec/controllers/admin/buster_controller_spec.rb +42 -0
- data/spec/lib/cache_buster_tags_spec.rb +20 -0
- data/spec/models/cache_buster_spec.rb +47 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- metadata +72 -0
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Cache Buster
|
2
|
+
|
3
|
+
Simply adds a tag which applies to a cache buster to any asset.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
<h1> Homepage </h1>
|
8
|
+
<img src="http://example.com/some/external/image.jpg<r:cache_buster/>">
|
9
|
+
|
10
|
+
## Configuration
|
11
|
+
|
12
|
+
# file: :radiant_root/config/initializers/radiant_config.rb
|
13
|
+
Radiant.config do |config|
|
14
|
+
config['cache_buster.timeout'] = 1.day
|
15
|
+
end
|
16
|
+
|
17
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Determine where the RSpec plugin is by loading the boot
|
2
|
+
unless defined? RADIANT_ROOT
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
case
|
5
|
+
when ENV["RADIANT_ENV_FILE"]
|
6
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
7
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
8
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
9
|
+
else
|
10
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
unless defined? RAILS_ROOT
|
15
|
+
case
|
16
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
17
|
+
RAILS_ROOT = "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}"
|
18
|
+
else
|
19
|
+
RAILS_ROOT = "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake'
|
24
|
+
require 'rake/rdoctask'
|
25
|
+
require 'rake/testtask'
|
26
|
+
|
27
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
28
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
29
|
+
require 'spec/rake/spectask'
|
30
|
+
require 'cucumber'
|
31
|
+
require 'cucumber/rake/task'
|
32
|
+
|
33
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
34
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
35
|
+
|
36
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
37
|
+
|
38
|
+
#task :default => [:spec, :cucumber]
|
39
|
+
task :default => [:spec]
|
40
|
+
task :stats => "spec:statsetup"
|
41
|
+
|
42
|
+
desc "Run all specs in spec directory"
|
43
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
44
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
45
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
46
|
+
end
|
47
|
+
|
48
|
+
namespace :spec do
|
49
|
+
desc "Run all specs in spec directory with RCov"
|
50
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
51
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
52
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
53
|
+
t.rcov = true
|
54
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Print Specdoc for all specs"
|
58
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
59
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
60
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
61
|
+
end
|
62
|
+
|
63
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
64
|
+
desc "Run the specs under spec/#{sub}"
|
65
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
66
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
67
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Run the Cucumber features"
|
72
|
+
task :integration => 'cucumber:ok'
|
73
|
+
|
74
|
+
# Setup specs for stats
|
75
|
+
task :statsetup do
|
76
|
+
require 'code_statistics'
|
77
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
78
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
79
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
80
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
81
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
82
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
83
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
84
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
85
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
86
|
+
end
|
87
|
+
|
88
|
+
namespace :db do
|
89
|
+
namespace :fixtures do
|
90
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
91
|
+
task :load => :environment do
|
92
|
+
require 'active_record/fixtures'
|
93
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
94
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
95
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
namespace :cucumber do
|
103
|
+
Cucumber::Rake::Task.new(:ok, 'Run features that should pass') do |t|
|
104
|
+
t.fork = true # You may get faster startup if you set this to false
|
105
|
+
t.profile = 'default'
|
106
|
+
end
|
107
|
+
|
108
|
+
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
109
|
+
t.fork = true # You may get faster startup if you set this to false
|
110
|
+
t.profile = 'wip'
|
111
|
+
end
|
112
|
+
|
113
|
+
desc 'Run all features'
|
114
|
+
task :all => [:ok, :wip]
|
115
|
+
end
|
116
|
+
|
117
|
+
desc 'Alias for cucumber:ok'
|
118
|
+
task :cucumber => 'cucumber:ok'
|
119
|
+
|
120
|
+
task :features => :cucumber do
|
121
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
122
|
+
end
|
123
|
+
|
124
|
+
desc 'Generate documentation for the sheets extension.'
|
125
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
126
|
+
rdoc.rdoc_dir = 'rdoc'
|
127
|
+
rdoc.title = 'SheetsExtension'
|
128
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
129
|
+
rdoc.rdoc_files.include('README')
|
130
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
131
|
+
end
|
132
|
+
|
133
|
+
# Load any custom rakefiles for extension
|
134
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Admin::BusterController < Admin::ResourceController
|
2
|
+
model_class CacheBuster
|
3
|
+
|
4
|
+
def index
|
5
|
+
if request.post?
|
6
|
+
if CacheBuster.bust_buster
|
7
|
+
flash[:notice] = "Cache Buster Reset - Succeeded!"
|
8
|
+
else
|
9
|
+
flash[:notice] = "Cache Buster Reset - FAILED!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class CacheBuster < ActiveRecord::Base
|
2
|
+
|
3
|
+
DEFAULT_TIMEOUT = 1.day
|
4
|
+
|
5
|
+
before_save :ensure_updated_at
|
6
|
+
|
7
|
+
def self.buster
|
8
|
+
self.there_can_be_only_one
|
9
|
+
|
10
|
+
if self.first.updated_at.to_i < Time.now.to_i-self.timeout
|
11
|
+
buster = self.bust_buster
|
12
|
+
else
|
13
|
+
buster = self.last
|
14
|
+
end
|
15
|
+
|
16
|
+
"?#{buster.updated_at.to_i}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.bust_buster
|
20
|
+
if self.first.nil?
|
21
|
+
self.new.save
|
22
|
+
else
|
23
|
+
self.first.save
|
24
|
+
end
|
25
|
+
self.first
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.timeout
|
29
|
+
(Radiant::Config['cache_buster.timeout'] ? Radiant::Config['cache_buster.timeout'].to_i : DEFAULT_TIMEOUT).to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def self.there_can_be_only_one
|
34
|
+
return self.new(:updated_at => Time.now).save if self.first.nil?
|
35
|
+
|
36
|
+
unless self.first == self.last
|
37
|
+
the_one = self.last
|
38
|
+
self.destroy_all
|
39
|
+
self.new(:updated_at => the_one.updated_at).save
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def ensure_updated_at
|
44
|
+
self.updated_at = Time.now
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Uncomment this if you reference any of your controllers in activate
|
2
|
+
require_dependency 'application_controller'
|
3
|
+
require 'compass'
|
4
|
+
require 'radiant-cache_buster-extension'
|
5
|
+
|
6
|
+
class CacheBusterExtension < Radiant::Extension
|
7
|
+
version RadiantCacheBusterExtension::VERSION
|
8
|
+
description RadiantCacheBusterExtension::DESCRIPTION
|
9
|
+
url RadiantCacheBusterExtension::URL
|
10
|
+
|
11
|
+
def activate
|
12
|
+
tab 'Settings' do
|
13
|
+
add_item "Cache Buster", "/admin/buster"
|
14
|
+
end
|
15
|
+
|
16
|
+
Page.class_eval do
|
17
|
+
include CacheBusterTags
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
map.namespace :admin do |admin|
|
3
|
+
admin.resources :buster
|
4
|
+
end
|
5
|
+
end
|
6
|
+
#ActionController::Routing::Routes.draw do |map|
|
7
|
+
#map.connect '/admin/buster', :controller => :buster, :action => :index, :conditions => { :method => [ :get, :post ] }
|
8
|
+
#end
|
9
|
+
|
10
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CacheBusterTags
|
2
|
+
include Radiant::Taggable
|
3
|
+
class TagError < StandardError; end
|
4
|
+
desc %{
|
5
|
+
Renders a cache buster.
|
6
|
+
|
7
|
+
*Usage:*
|
8
|
+
|
9
|
+
<pre><code><img src="http://example.com/some/external/image.png<r:cache_buster /></code>"></pre>
|
10
|
+
|
11
|
+
The above example will produce the following:
|
12
|
+
|
13
|
+
<pre><code><img src="http://example.com/some/external/image.png?123456789</code>"></pre>
|
14
|
+
}
|
15
|
+
tag 'cache_buster' do |tag|
|
16
|
+
CacheBuster.buster
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :cache_buster do
|
4
|
+
desc "Runs the migration of the CacheBuster extension"
|
5
|
+
task :migrate => :environment do
|
6
|
+
require 'radiant/extension_migrator'
|
7
|
+
if ENV["VERSION"]
|
8
|
+
CacheBusterExtension.migrator.migrate(ENV["VERSION"].to_i)
|
9
|
+
Rake::Task['db:schema:dump'].invoke
|
10
|
+
else
|
11
|
+
CacheBusterExtension.migrator.migrate
|
12
|
+
Rake::Task['db:schema:dump'].invoke
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-cache_buster-extension"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-cache_buster-extension"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
|
9
|
+
s.version = RadiantCacheBusterExtension::VERSION
|
10
|
+
s.authors = RadiantCacheBusterExtension::AUTHORS
|
11
|
+
s.email = RadiantCacheBusterExtension::EMAIL
|
12
|
+
s.homepage = RadiantCacheBusterExtension::URL
|
13
|
+
s.summary = RadiantCacheBusterExtension::SUMMARY
|
14
|
+
s.description = RadiantCacheBusterExtension::DESCRIPTION
|
15
|
+
|
16
|
+
ignores = if File.exist?('.gitignore')
|
17
|
+
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
|
18
|
+
else
|
19
|
+
[]
|
20
|
+
end
|
21
|
+
s.files = Dir['**/*'] - ignores
|
22
|
+
s.test_files = Dir['spec/**/*'] - ignores
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# all 'test's before 'ue' or will exit when test fails
|
4
|
+
|
5
|
+
test "$WITH_RVM" || WITH_RVM="true"
|
6
|
+
test "$RADIANT_VERSION" || RADIANT_VERSION="1.1.0"
|
7
|
+
test "$DB" || DB="sqlite"
|
8
|
+
test -e ~/radiant && rm -rf ~/radiant
|
9
|
+
|
10
|
+
|
11
|
+
set -xue
|
12
|
+
|
13
|
+
start_path="$( pwd )"
|
14
|
+
|
15
|
+
cd ~
|
16
|
+
git clone git://github.com/radiant/radiant.git
|
17
|
+
cd ~/radiant
|
18
|
+
|
19
|
+
if [[ $RADIANT_VERSION != "master" ]]
|
20
|
+
then
|
21
|
+
git checkout -b $RADIANT_VERSION $RADIANT_VERSION
|
22
|
+
fi
|
23
|
+
|
24
|
+
cp -r $start_path vendor/extensions/cache_buster
|
25
|
+
gem install bundler --no-ri --no-rdoc
|
26
|
+
|
27
|
+
echo 'gem "radiant-cache_buster-extension", :path => "vendor/extensions/cache_buster"' >> Gemfile
|
28
|
+
echo 'gemspec' >> Gemfile
|
29
|
+
|
30
|
+
# I really dislike using rvm gemset, but while testing this
|
31
|
+
# script I got sick having to install the same gems over and
|
32
|
+
# over again.
|
33
|
+
if [[ $WITH_RVM == "true" ]]; then
|
34
|
+
rvm gemset create radiant_development
|
35
|
+
rvm gemset use radiant_development
|
36
|
+
bundle install
|
37
|
+
else
|
38
|
+
bundle install --path ./vendor/bundle
|
39
|
+
fi
|
40
|
+
|
41
|
+
case $DB in
|
42
|
+
"mysql" )
|
43
|
+
mysql -e 'create database radiant_test;'
|
44
|
+
cp spec/ci/database.mysql.yml config/database.yml;;
|
45
|
+
"postgres" )
|
46
|
+
psql -c 'create database radiant_test;' -U postgres
|
47
|
+
cp spec/ci/database.postgresql.yml config/database.yml;;
|
48
|
+
"sqlite" )
|
49
|
+
cp spec/ci/database.sqlite.yml config/database.yml;;
|
50
|
+
esac
|
51
|
+
|
52
|
+
RAILS_ENV=test bundle exec rake db:migrate --trace
|
53
|
+
RAILS_ENV=test bundle exec rake db:migrate:extensions --trace
|
data/spec/ci/script
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# all 'test's before 'ue' or will exit when test fails
|
4
|
+
test "$WITH_RVM" || WITH_RVM="true"
|
5
|
+
|
6
|
+
set -xue
|
7
|
+
|
8
|
+
start_path="$( pwd )"
|
9
|
+
|
10
|
+
# I really dislike using rvm gemset, but while testing this
|
11
|
+
# script I got sick having to install the same gems over and
|
12
|
+
# over again.
|
13
|
+
if [[ $WITH_RVM == "true" ]]; then
|
14
|
+
rvm gemset create radiant_development
|
15
|
+
rvm gemset use radiant_development
|
16
|
+
fi
|
17
|
+
|
18
|
+
cd ~/radiant
|
19
|
+
|
20
|
+
# ensure fresh cache_buster code
|
21
|
+
rm -rf vendor/extensions/cache_buster
|
22
|
+
cp -r $start_path vendor/extensions/cache_buster
|
23
|
+
bundle update radiant-cache_buster-extension
|
24
|
+
|
25
|
+
RAILS_ENV=test bundle exec rake spec:extensions EXT=cache_buster --trace
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Admin::BusterController do
|
4
|
+
dataset :users
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
ActionController::Routing::Routes.reload
|
8
|
+
login_as :designer
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be a ResourceController" do
|
12
|
+
controller.should be_kind_of(Admin::ResourceController)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should handle CacheBuster" do
|
16
|
+
controller.class.model_class.should == CacheBuster
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "index" do
|
20
|
+
describe "display Buster" do
|
21
|
+
before do
|
22
|
+
get :index
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should render the index view" do
|
26
|
+
response.should be_success
|
27
|
+
response.should render_template('index')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "update Buster" do
|
32
|
+
before do
|
33
|
+
post :index
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should render the index view" do
|
37
|
+
response.should be_success
|
38
|
+
response.should render_template('index')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# require 'spec_helper'
|
2
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
3
|
+
|
4
|
+
#class Time
|
5
|
+
#def self.now
|
6
|
+
#Time.at 1212483780 # July 3 2008 9:03AM PST
|
7
|
+
#end
|
8
|
+
#end
|
9
|
+
|
10
|
+
describe "Cache Buster Tags" do
|
11
|
+
dataset :pages, :users
|
12
|
+
|
13
|
+
let(:page){ pages(:home) }
|
14
|
+
|
15
|
+
describe "<r:cache_buster />" do
|
16
|
+
subject { page }
|
17
|
+
it { should render(%{<r:cache_buster />}).as(/\?[0-9]+$/) }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe CacheBuster do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
# ensure default after previous tests
|
7
|
+
Radiant::Config['cache_buster.timeout'] = CacheBuster::DEFAULT_TIMEOUT
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.buster' do
|
11
|
+
it 'should return cache buster' do
|
12
|
+
CacheBuster.buster.should be
|
13
|
+
end
|
14
|
+
it 'should be a string' do
|
15
|
+
CacheBuster.buster.should be_a_kind_of String
|
16
|
+
CacheBuster.buster.should match /^\?[0-9]+$/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.timeout' do
|
21
|
+
describe 'without timeout config' do
|
22
|
+
it 'should be an int' do
|
23
|
+
CacheBuster.timeout.should be_a_kind_of Fixnum
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe 'with timeout config' do
|
27
|
+
before do
|
28
|
+
Radiant::Config['cache_buster.timeout'] = 1
|
29
|
+
end
|
30
|
+
it 'should be an int' do
|
31
|
+
CacheBuster.timeout.should be_a_kind_of Fixnum
|
32
|
+
CacheBuster.timeout.should == 1
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should update after timeout passes' do
|
36
|
+
|
37
|
+
buster1 = CacheBuster.buster
|
38
|
+
sleep 2
|
39
|
+
buster2 = CacheBuster.buster
|
40
|
+
|
41
|
+
buster1.should_not == buster2
|
42
|
+
#buster1.gsub("?", "").to_i.should be_less_then buster2.gsub("?", "").to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
|
16
|
+
#if File.directory?(File.dirname(__FILE__) + "/matchers")
|
17
|
+
#Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
|
18
|
+
#end
|
19
|
+
|
20
|
+
Spec::Runner.configure do |config|
|
21
|
+
# config.use_transactional_fixtures = true
|
22
|
+
# config.use_instantiated_fixtures = false
|
23
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures'
|
24
|
+
|
25
|
+
# You can declare fixtures for each behaviour like this:
|
26
|
+
# describe "...." do
|
27
|
+
# fixtures :table_a, :table_b
|
28
|
+
#
|
29
|
+
# Alternatively, if you prefer to declare them only once, you can
|
30
|
+
# do so here, like so ...
|
31
|
+
#
|
32
|
+
# config.global_fixtures = :table_a, :table_b
|
33
|
+
#
|
34
|
+
# If you declare global fixtures, be aware that they will be declared
|
35
|
+
# for all of your examples, even those that don't use them.
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-cache_buster-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josh Mervine
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-12 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Cache Buster tag for Radiant CMS
|
15
|
+
email:
|
16
|
+
- joshua@mervine.net
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- config/routes.rb
|
22
|
+
- app/models/cache_buster.rb
|
23
|
+
- app/controllers/admin/buster_controller.rb
|
24
|
+
- app/views/admin/buster/index.html.haml
|
25
|
+
- README.md
|
26
|
+
- db/migrate/002_create_inital_cache_buster.rb
|
27
|
+
- db/migrate/001_create_cache_buster.rb
|
28
|
+
- radiant-cache_buster-extension.gemspec
|
29
|
+
- spec/models/cache_buster_spec.rb
|
30
|
+
- spec/controllers/admin/buster_controller_spec.rb
|
31
|
+
- spec/ci/script
|
32
|
+
- spec/ci/before_script
|
33
|
+
- spec/spec.opts
|
34
|
+
- spec/spec_helper.rb
|
35
|
+
- spec/lib/cache_buster_tags_spec.rb
|
36
|
+
- lib/radiant-cache_buster-extension.rb
|
37
|
+
- lib/tasks/cache_buster_extension_tasks.rake
|
38
|
+
- lib/cache_buster_tags.rb
|
39
|
+
- cache_buster_extension.rb
|
40
|
+
- Rakefile
|
41
|
+
homepage: http://github.com/jmervine/radiant-cache_buster-extension
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.24
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Cache Buster tag for Radiant CMS
|
65
|
+
test_files:
|
66
|
+
- spec/models/cache_buster_spec.rb
|
67
|
+
- spec/controllers/admin/buster_controller_spec.rb
|
68
|
+
- spec/ci/script
|
69
|
+
- spec/ci/before_script
|
70
|
+
- spec/spec.opts
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spec/lib/cache_buster_tags_spec.rb
|