klarlack 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -40,4 +40,4 @@ http://dict.leo.org/?search=klarlack
40
40
 
41
41
  === Copyright
42
42
 
43
- Copyright (c) 2009 Max Schöfmann. Distributed under the MIT-License
43
+ Copyright (c) 2009-2010 Max Schöfmann. Distributed under the MIT-License
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 4
3
+ :patch: 5
4
4
  :major: 0
data/lib/klarlack.rb CHANGED
@@ -3,5 +3,5 @@ require 'varnish/socket_factory'
3
3
  require 'varnish/client'
4
4
 
5
5
  module Varnish
6
- VERSION = '0.0.4'
6
+ VERSION = '0.0.5'
7
7
  end
@@ -117,13 +117,17 @@ module Varnish
117
117
 
118
118
  # Purge objects from the cache or show the purge queue.
119
119
  #
120
+ # Takes one or two arguments:
121
+ #
122
+ # 1.
120
123
  # .purge :url, <regexp>
121
124
  # .purge :hash, <regexp>
122
- # .purge :list
123
- # .purge <costum-field> <args>
124
125
  #
125
- # +op+:: :url, :hash, :list or a custom field
126
- # +regexp+:: a string containing a varnish compatible regexp
126
+ # <regexp> is a string containing a varnish compatible regexp
127
+ #
128
+ # 2.
129
+ # .purge <costum-purge-conditions>
130
+ # .purge :list
127
131
  #
128
132
  # Returns true for purging, returns an array containing the purge queue
129
133
  # for :list
@@ -132,14 +136,17 @@ module Varnish
132
136
  # v = Varnish::Client.new
133
137
  # v.purge :url, '.*'
134
138
  #
139
+ # v.purge "req.http.host ~ www.foo.com && req.http.url ~ images"
140
+ #
135
141
  # v.purge :list
136
142
  # #=> [[1, "req.url ~ .*"]]
137
143
  #
138
- def purge(op, *regexp_or_args)
139
- c = [:url, :hash, :list].include?(op) ? "purge.#{op}" : "purge #{op}"
140
- response = cmd(c, *regexp_or_args)
141
- case op
142
- when :list
144
+ def purge(*args)
145
+ c = 'purge'
146
+ c << ".#{args.shift}" if [:url, :hash, :list].include?(args.first)
147
+ response = cmd(c, *args)
148
+ case c
149
+ when 'purge.list'
143
150
  response.split("\n").map do |line|
144
151
  a = line.split("\t")
145
152
  [a[0].to_i, a[1]]
@@ -82,6 +82,7 @@ describe Varnish::Client do
82
82
  @varnish.purge(:url, '^/articles/.*').should be_true
83
83
  @varnish.purge(:hash, 12345).should be_true
84
84
  @varnish.purge("req.http.host", "~", "www.example.com").should be_true
85
+ @varnish.purge("req.http.host ~ www.example.com").should be_true
85
86
  end
86
87
 
87
88
  it '#purge with :list should return an array with queued purges' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klarlack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Max Sch\xC3\xB6fmann"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-03 00:00:00 +01:00
12
+ date: 2010-02-04 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15