lacquer 0.5.0.beta1 → 0.5.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
1
+ --- {}
2
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0.beta1
1
+ 0.5.0.beta2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lacquer}
8
- s.version = "0.5.0.beta1"
8
+ s.version = "0.5.0.beta2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Russ Smith (russ@bashme.org)", "Ryan Johns", "Garry Tan (garry@posterous.com), Gabe da Silveira (gabe@websaviour.com)", "Håkon Lerring"]
12
- s.date = %q{2011-04-25}
12
+ s.date = %q{2011-05-26}
13
13
  s.description = %q{Rails drop in for Varnish support.}
14
14
  s.email = %q{russ@bashme.org}
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  ]
60
60
  s.homepage = %q{http://github.com/russ/lacquer}
61
61
  s.require_paths = ["lib"]
62
- s.rubygems_version = %q{1.5.0}
62
+ s.rubygems_version = %q{1.6.2}
63
63
  s.summary = %q{Rails drop in for Varnish support.}
64
64
  s.test_files = [
65
65
  "spec/lacquer/cache_control_spec.rb",
@@ -15,7 +15,7 @@ module Lacquer
15
15
  def register(group, options = {})
16
16
  options[:group] = group
17
17
  options[:args] = Array(options[:args]).compact
18
- store << options
18
+ store << options
19
19
  end
20
20
 
21
21
  def configure
@@ -46,16 +46,23 @@ module Lacquer
46
46
  CODE
47
47
  end.join("\n")
48
48
  end
49
+
50
+ def to_vcl_pass_urls
51
+ <<-CODE.strip_heredoc
52
+ if(#{to_vcl_conditions(urls_by(:pass))}) {
53
+ return(pass);
54
+ }
55
+ CODE
56
+ end
49
57
 
50
- protected
58
+ protected
51
59
 
52
60
  def urls_grouped_by_expires
53
61
  store.group_by { |opt| opt[:expires_in] }.select { |expires_in, list| expires_in }
54
62
  end
55
63
 
56
64
  def urls_by(group)
57
- store.select { |opt| opt[:group] == group }
65
+ store.select { |opt| opt[:group] == group }
58
66
  end
59
-
60
67
  end
61
68
  end
@@ -1,37 +1,37 @@
1
- namespace :varnishd do
2
-
3
- desc "Start varnishd daemon using Lacquer's settings"
4
- task :start => :environment do
5
- Lacquer::Varnishd.new.start
6
- end
7
-
8
- desc "Stop varnishd daemon using Lacquer's settings"
9
- task :stop => :environment do
10
- Lacquer::Varnishd.new.stop
11
- end
12
-
13
- desc "Running status of varnishd daemon using Lacquer's settings"
14
- task :status => :environment do
15
- if Lacquer::Varnishd.new.running?
16
- puts "Varnishd is running"
17
- else
18
- puts "Varnishd is not running"
1
+ namespace :lacquer do
2
+ namespace :varnishd do
3
+ desc "Start varnishd daemon using Lacquer's settings"
4
+ task :start => :environment do
5
+ Lacquer::Varnishd.new.start
19
6
  end
20
- end
21
-
22
- desc "Restart varnishd daemon using Lacquer's settings"
23
- task :restart => :environment do
24
- varnishd = Lacquer::Varnishd.new
25
- if varnishd.running?
26
- varnishd.stop
27
- sleep(1)
7
+
8
+ desc "Stop varnishd daemon using Lacquer's settings"
9
+ task :stop => :environment do
10
+ Lacquer::Varnishd.new.stop
28
11
  end
29
- varnishd.start
30
- end
31
-
32
- desc "Purge ALL urls from Varnish"
33
- task :global_purge => :environment do
34
- Lacquer::Varnish.new.purge('.*')
35
- end
36
12
 
37
- end
13
+ desc "Running status of varnishd daemon using Lacquer's settings"
14
+ task :status => :environment do
15
+ if Lacquer::Varnishd.new.running?
16
+ puts "Varnishd is running"
17
+ else
18
+ puts "Varnishd is not running"
19
+ end
20
+ end
21
+
22
+ desc "Restart varnishd daemon using Lacquer's settings"
23
+ task :restart => :environment do
24
+ varnishd = Lacquer::Varnishd.new
25
+ if varnishd.running?
26
+ varnishd.stop
27
+ sleep(1)
28
+ end
29
+ varnishd.start
30
+ end
31
+
32
+ desc "Purge ALL urls from Varnish"
33
+ task :global_purge => :environment do
34
+ Lacquer::Varnish.new.purge('.*')
35
+ end
36
+ end
37
+ end
@@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
2
  require 'lacquer/cache_control'
3
3
 
4
4
  describe Lacquer::CacheControl do
5
-
6
5
  describe "#register" do
7
-
8
6
  it "persists cache settings for url" do
9
7
  cache_control = described_class.new
10
8
  cache_control.register :class_section, :url => "^/sv/class_sections/%s.*$", :args => "[0-9]+"
@@ -12,21 +10,17 @@ describe Lacquer::CacheControl do
12
10
  cache_control.store.first[:url].should == "^/sv/class_sections/%s.*$"
13
11
  cache_control.store.first[:args].should == ["[0-9]+"]
14
12
  end
15
-
16
13
  end
17
14
 
18
15
  describe "#urls_for" do
19
-
20
16
  it "returns urls to expire for object" do
21
17
  cache_control = described_class.new
22
18
  cache_control.register :class_section, :url => "^/sv/class_sections/%s.*$", :args => "[0-9]+"
23
19
  cache_control.urls_for(:class_section, mock("ClassSection", :to_param => 1)).should == ["^/sv/class_sections/1.*$"]
24
20
  end
25
-
26
21
  end
27
22
 
28
23
  context "vcl" do
29
-
30
24
  it "returns all urls as vcl conditions" do
31
25
  cache_control = described_class.new
32
26
  cache_control.register :class_section, :url => "^/sv/class_sections/%s.*$", :args => "[0-9]+"
@@ -37,12 +31,14 @@ describe Lacquer::CacheControl do
37
31
  conditions.should include("||")
38
32
  conditions.should include("req.url ~ \"^/sv/info_screens/[0-9]+.*$\"")
39
33
  end
40
-
41
- # if (req.url ~ "^/images" || req.url ~ "^/stylesheets" || req.url ~ "^/javascripts") {
42
- # unset beresp.http.Set-Cookie;
43
- # set beresp.ttl = 7d;
44
- # return(deliver);
45
- # }
34
+
35
+ it "returns vcl for pass urls" do
36
+ cache_control = described_class.new
37
+ cache_control.register :pass, :url => "^/admin"
38
+ pass_urls = cache_control.to_vcl_pass_urls
39
+ pass_urls.should include('if(req.url ~ "^/admin")')
40
+ pass_urls.should include('return(pass)')
41
+ end
46
42
 
47
43
  it "returns vcl for override ttl on beresp" do
48
44
  cache_control = described_class.new
@@ -66,7 +62,5 @@ describe Lacquer::CacheControl do
66
62
  override_ttl.should include('set beresp.ttl = 2d')
67
63
  override_ttl.should_not include('info_screen')
68
64
  end
69
-
70
65
  end
71
-
72
66
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: lacquer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.5.0.beta1
5
+ version: 0.5.0.beta2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Russ Smith (russ@bashme.org)
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-04-25 00:00:00 -07:00
16
+ date: 2011-05-26 00:00:00 -07:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
- hash: 1714554342870495979
148
+ hash: -3766237804687005337
149
149
  segments:
150
150
  - 0
151
151
  version: "0"
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  requirements: []
159
159
 
160
160
  rubyforge_project:
161
- rubygems_version: 1.5.0
161
+ rubygems_version: 1.6.2
162
162
  signing_key:
163
163
  specification_version: 3
164
164
  summary: Rails drop in for Varnish support.