shellac 0.0.1 → 0.0.2
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/VERSION +1 -1
- data/lib/generators/templates/config/varnish.yml +25 -0
- data/lib/shellac.rb +8 -4
- data/lib/shellac/actions.rb +3 -5
- data/lib/shellac/cache.rb +5 -5
- data/shellac.gemspec +2 -1
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Define varnish for all environments that make use of it.
|
2
|
+
# Currently all options must be specified. This will change in a future
|
3
|
+
# version to only need definition of non default values of varnish.
|
4
|
+
|
5
|
+
# host: The host which you access your varnish server from. This
|
6
|
+
# is particularly useful when you cache more than one host
|
7
|
+
# with one varnish instance (default: localhost)
|
8
|
+
|
9
|
+
# post: The port of your varnish telnet server (default: 6082)
|
10
|
+
|
11
|
+
# timeout: Timeout in seconds when connecting to varnish (default: 1)
|
12
|
+
|
13
|
+
# keep_alive: Set to true, to keep the connection alive (default: false)
|
14
|
+
|
15
|
+
development:
|
16
|
+
host: localhost
|
17
|
+
port: 6082
|
18
|
+
timeout: 1
|
19
|
+
keep_alive: false
|
20
|
+
|
21
|
+
production:
|
22
|
+
host: example.com
|
23
|
+
port: 6082
|
24
|
+
timeout: 1
|
25
|
+
keep_alive: false
|
data/lib/shellac.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'klarlack'
|
3
3
|
|
4
|
-
class
|
4
|
+
class Railtie < Rails::Railtie
|
5
5
|
|
6
|
-
config.
|
7
|
-
require 'shellac/cache'
|
8
|
-
require 'shellac/actions'
|
6
|
+
config.before_initialize do
|
7
|
+
require File.expand_path('../shellac/cache', __FILE__)
|
8
|
+
require File.expand_path('../shellac/actions', __FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
config.to_prepare do
|
12
|
+
ActionController::Base.send :extend, Shellac::Actions
|
9
13
|
end
|
10
14
|
|
11
15
|
end
|
data/lib/shellac/actions.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
module Shellac
|
2
2
|
module Actions
|
3
3
|
|
4
|
-
def purge regex
|
4
|
+
def purge regex, recursive=false
|
5
5
|
return unless perform_caching
|
6
|
-
Shellac::Cache.instance.purge regex
|
6
|
+
Shellac::Cache.instance.purge regex, recursive
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
10
|
-
end
|
11
|
-
|
12
|
-
ActionController::Base.send :include, Shellac::Actions
|
10
|
+
end
|
data/lib/shellac/cache.rb
CHANGED
@@ -6,13 +6,13 @@ module Shellac
|
|
6
6
|
|
7
7
|
# return client instance
|
8
8
|
def client
|
9
|
-
@client ||= Varnish::Client.new
|
10
|
-
|
11
|
-
|
9
|
+
@client ||= Varnish::Client.new "#{config("host")}:#{config("port")}",
|
10
|
+
:timeout => config("timeout"),
|
11
|
+
:keep_alive => config("keep_alive")
|
12
12
|
end
|
13
13
|
|
14
14
|
# purge a regular expression of url
|
15
|
-
def purge path, recursive
|
15
|
+
def purge path, recursive
|
16
16
|
|
17
17
|
if recursive
|
18
18
|
regex = "^#{path}" # purge any page starting with regex
|
@@ -21,7 +21,7 @@ module Shellac
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# write to log
|
24
|
-
Rails.logger.info "Purging#{" (recursively)" if recursive}: #{path}"
|
24
|
+
Rails.logger.info "*** Purging#{" (recursively)" if recursive}: #{path}"
|
25
25
|
|
26
26
|
# purge with
|
27
27
|
client.purge "req.http.host ~ ^#{config("host")} && req.url ~ #{regex}"
|
data/shellac.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{shellac}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marian"]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"lib/generators/shellac/install_generator.rb",
|
28
|
+
"lib/generators/templates/config/varnish.yml",
|
28
29
|
"lib/generators/templates/varnish.yml",
|
29
30
|
"lib/shellac.rb",
|
30
31
|
"lib/shellac/actions.rb",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: shellac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marian
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- VERSION
|
99
99
|
- lib/generators/shellac/install_generator.rb
|
100
|
+
- lib/generators/templates/config/varnish.yml
|
100
101
|
- lib/generators/templates/varnish.yml
|
101
102
|
- lib/shellac.rb
|
102
103
|
- lib/shellac/actions.rb
|
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
119
|
requirements:
|
119
120
|
- - ">="
|
120
121
|
- !ruby/object:Gem::Version
|
121
|
-
hash:
|
122
|
+
hash: -1649615466522431169
|
122
123
|
segments:
|
123
124
|
- 0
|
124
125
|
version: "0"
|