solvent 0.1.0

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/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "solvent"
5
+ gemspec.summary = "Simple Ruby Library for expiring Varnish caches"
6
+ gemspec.description = "Simple Ruby library for expiring Varnish caches.
7
+ It currently relies on my own fork of Typhoeus, and that's not available as a gem...
8
+ So this is pretty much unusable. Just throwing it up here as an example until the
9
+ fixes I need get into Typhoeus::Easy"
10
+ gemspec.email = "ryan@angilly.com"
11
+ gemspec.homepage = "http://github.com/ryana/solvent"
12
+ gemspec.authors = ["Ryan Angilly"]
13
+
14
+ gemspec.add_dependency 'typhoeus', '0.1.27'
15
+
16
+ gemspec.add_development_dependency 'shoulda', '2.11.0'
17
+ gemspec.add_development_dependency 'mocha', '0.9.8'
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: gem install jeweler"
22
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/solvent.rb ADDED
@@ -0,0 +1,22 @@
1
+ class Solvent
2
+
3
+ def self.expire url
4
+ new(url).expire
5
+ end
6
+
7
+ attr_accessor :url, :status
8
+
9
+ def initialize url
10
+ self.url = url
11
+ end
12
+
13
+ def expire
14
+ e = Typhoeus::Easy.new
15
+ e.url = url
16
+ e.method = :purge
17
+ self.status = e.perform
18
+
19
+ self.status == 200
20
+ end
21
+
22
+ end
data/solvent.gemspec ADDED
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{solvent}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ryan Angilly"]
12
+ s.date = %q{2010-06-23}
13
+ s.description = %q{Simple Ruby library for expiring Varnish caches.
14
+ It currently relies on my own fork of Typhoeus, and that's not available as a gem...
15
+ So this is pretty much unusable. Just throwing it up here as an example until the
16
+ fixes I need get into Typhoeus::Easy}
17
+ s.email = %q{ryan@angilly.com}
18
+ s.files = [
19
+ "Rakefile",
20
+ "VERSION",
21
+ "lib/solvent.rb",
22
+ "solvent.gemspec",
23
+ "test/test_helper.rb",
24
+ "test/unit/test_helper.rb",
25
+ "test/unit/test_solvent.rb",
26
+ "vcl/varnish.vcl"
27
+ ]
28
+ s.homepage = %q{http://github.com/ryana/solvent}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.6}
32
+ s.summary = %q{Simple Ruby Library for expiring Varnish caches}
33
+ s.test_files = [
34
+ "test/test_helper.rb",
35
+ "test/unit/test_helper.rb",
36
+ "test/unit/test_solvent.rb"
37
+ ]
38
+
39
+ if s.respond_to? :specification_version then
40
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<typhoeus>, ["= 0.1.27"])
45
+ s.add_development_dependency(%q<shoulda>, ["= 2.11.0"])
46
+ s.add_development_dependency(%q<mocha>, ["= 0.9.8"])
47
+ else
48
+ s.add_dependency(%q<typhoeus>, ["= 0.1.27"])
49
+ s.add_dependency(%q<shoulda>, ["= 2.11.0"])
50
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<typhoeus>, ["= 0.1.27"])
54
+ s.add_dependency(%q<shoulda>, ["= 2.11.0"])
55
+ s.add_dependency(%q<mocha>, ["= 0.9.8"])
56
+ end
57
+ end
58
+
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+ require 'typhoeus'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
7
+ require 'solvent'
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
@@ -0,0 +1,36 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class SolventTest < Test::Unit::TestCase
4
+
5
+ context "Solvent" do
6
+ should "have .expires that creates new instance" do
7
+ url = "oh hi"
8
+ ve_stub = stub('VeStub', :expire => "1")
9
+ Solvent.expects(:new).with(url).returns ve_stub
10
+
11
+ assert_equal "1", Solvent.expire(url)
12
+ end
13
+ end
14
+
15
+ context "A Solvent" do
16
+ setup do
17
+ @url = "my url"
18
+ @ve = Solvent.new(@url)
19
+ end
20
+
21
+ should "create a new Typhoeus::Easy and set method to purge" do
22
+ Typhoeus::Easy.any_instance.expects('method=').with(:purge).once
23
+ Typhoeus::Easy.any_instance.expects('perform').once.returns 200
24
+
25
+ assert_nil @ve.status
26
+ assert_equal true, @ve.expire
27
+ assert_equal 200, @ve.status
28
+ end
29
+
30
+ should "return false when expire does not expire" do
31
+ Typhoeus::Easy.any_instance.expects('perform').once.returns 404
32
+
33
+ assert_equal false, @ve.expire
34
+ end
35
+ end
36
+ end
data/vcl/varnish.vcl ADDED
@@ -0,0 +1,35 @@
1
+ backend mpb {
2
+ .host = "dev.mypunchbowl.com";
3
+ .port = "3000";
4
+ }
5
+
6
+ sub vcl_recv {
7
+ set req.http.post = "dev.mypunchbowl.com";
8
+ set req.backend = mpb;
9
+
10
+ if (req.url ~ "^/gridfs/" || req.url ~ "^/stylesheets/" || req.url ~ "^/javascripts/") {
11
+ if (req.request == "GET") {
12
+ unset req.http.cookie;
13
+ unset req.http.Authorization;
14
+ lookup;
15
+ } elsif (req.request == "PURGE") {
16
+ lookup;
17
+ }
18
+ }
19
+
20
+ pass;
21
+ }
22
+
23
+ # Note that setting ttl to 0 is magical. the object is zapped from cache.
24
+ sub vcl_hit {
25
+ if (req.request == "PURGE") {
26
+ set obj.ttl = 0s;
27
+ error 200 "Purged.";
28
+ }
29
+ }
30
+
31
+ sub vcl_miss {
32
+ if (req.request == "PURGE") {
33
+ error 404 "Not in cache.";
34
+ }
35
+ }
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solvent
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Ryan Angilly
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-23 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: typhoeus
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 1
30
+ - 27
31
+ version: 0.1.27
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: shoulda
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 11
44
+ - 0
45
+ version: 2.11.0
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: mocha
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 9
58
+ - 8
59
+ version: 0.9.8
60
+ type: :development
61
+ version_requirements: *id003
62
+ description: |-
63
+ Simple Ruby library for expiring Varnish caches.
64
+ It currently relies on my own fork of Typhoeus, and that's not available as a gem...
65
+ So this is pretty much unusable. Just throwing it up here as an example until the
66
+ fixes I need get into Typhoeus::Easy
67
+ email: ryan@angilly.com
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - Rakefile
76
+ - VERSION
77
+ - lib/solvent.rb
78
+ - solvent.gemspec
79
+ - test/test_helper.rb
80
+ - test/unit/test_helper.rb
81
+ - test/unit/test_solvent.rb
82
+ - vcl/varnish.vcl
83
+ has_rdoc: true
84
+ homepage: http://github.com/ryana/solvent
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --charset=UTF-8
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.3.6
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Simple Ruby Library for expiring Varnish caches
113
+ test_files:
114
+ - test/test_helper.rb
115
+ - test/unit/test_helper.rb
116
+ - test/unit/test_solvent.rb