actionpack-page_caching 1.0.2 → 1.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.
Potentially problematic release.
This version of actionpack-page_caching might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.codeclimate.yml +7 -0
- data/.gitignore +3 -15
- data/.rubocop.yml +116 -0
- data/.travis.yml +39 -0
- data/CHANGELOG.md +31 -6
- data/Gemfile +2 -2
- data/README.md +62 -17
- data/Rakefile +5 -5
- data/actionpack-page_caching.gemspec +14 -13
- data/gemfiles/Gemfile-4-0-stable +4 -3
- data/gemfiles/Gemfile-4-1-stable +6 -0
- data/gemfiles/Gemfile-4-2-stable +10 -0
- data/gemfiles/Gemfile-5-0-stable +5 -0
- data/gemfiles/Gemfile-edge +4 -3
- data/lib/action_controller/caching/pages.rb +182 -76
- data/lib/action_controller/page_caching.rb +1 -1
- data/lib/actionpack/page_caching.rb +1 -1
- data/lib/actionpack/page_caching/railtie.rb +5 -5
- data/test/abstract_unit.rb +9 -19
- data/test/caching_test.rb +345 -86
- data/test/log_subscriber_test.rb +20 -17
- metadata +23 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcc463b295ac09cfa6b0ca15557d7e00da2bf92b
|
4
|
+
data.tar.gz: 1ca39e53842cb9446214249e47cfe791596e763e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd19ec3f9214460795607de16e4d66769b7621cac4caa329ada8ec810b9414a6f1e5280b8132d683adcba70343b85750356c8d0d3d017f7d98ed199384ad1b14
|
7
|
+
data.tar.gz: afa5b80f7c9ce7c54e284fa35bc3c484d7c0552aff051999dd668edd99827059570b019a01e00da544d23c68a78e9427354f68e5b36981221fc808f38f283912
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
4
|
+
# to ignore them, so only the ones explicitly set in this file are enabled.
|
5
|
+
DisabledByDefault: true
|
6
|
+
|
7
|
+
# Prefer &&/|| over and/or.
|
8
|
+
Style/AndOr:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
# Do not use braces for hash literals when they are the last argument of a
|
12
|
+
# method call.
|
13
|
+
Style/BracesAroundHashParameters:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
# Align `when` with `case`.
|
17
|
+
Style/CaseIndentation:
|
18
|
+
Enabled: true
|
19
|
+
|
20
|
+
# Align comments with method definitions.
|
21
|
+
Style/CommentIndentation:
|
22
|
+
Enabled: true
|
23
|
+
|
24
|
+
# No extra empty lines.
|
25
|
+
Style/EmptyLines:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
# In a regular class definition, no empty lines around the body.
|
29
|
+
Style/EmptyLinesAroundClassBody:
|
30
|
+
Enabled: true
|
31
|
+
|
32
|
+
# In a regular module definition, no empty lines around the body.
|
33
|
+
Style/EmptyLinesAroundModuleBody:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
37
|
+
Style/HashSyntax:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
# Method definitions after `private` or `protected` isolated calls need one
|
41
|
+
# extra level of indentation.
|
42
|
+
Style/IndentationConsistency:
|
43
|
+
Enabled: true
|
44
|
+
EnforcedStyle: rails
|
45
|
+
|
46
|
+
# Two spaces, no tabs (for indentation).
|
47
|
+
Style/IndentationWidth:
|
48
|
+
Enabled: true
|
49
|
+
|
50
|
+
Style/SpaceAfterColon:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
Style/SpaceAfterComma:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
57
|
+
Enabled: true
|
58
|
+
|
59
|
+
Style/SpaceAroundKeyword:
|
60
|
+
Enabled: true
|
61
|
+
|
62
|
+
Style/SpaceAroundOperators:
|
63
|
+
Enabled: true
|
64
|
+
|
65
|
+
Style/SpaceBeforeFirstArg:
|
66
|
+
Enabled: true
|
67
|
+
|
68
|
+
# Defining a method with parameters needs parentheses.
|
69
|
+
Style/MethodDefParentheses:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
# Use `foo {}` not `foo{}`.
|
73
|
+
Style/SpaceBeforeBlockBraces:
|
74
|
+
Enabled: true
|
75
|
+
|
76
|
+
# Use `foo { bar }` not `foo {bar}`.
|
77
|
+
Style/SpaceInsideBlockBraces:
|
78
|
+
Enabled: true
|
79
|
+
|
80
|
+
# Use `{ a: 1 }` not `{a:1}`.
|
81
|
+
Style/SpaceInsideHashLiteralBraces:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Style/SpaceInsideParens:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
# Check quotes usage according to lint rule below.
|
88
|
+
Style/StringLiterals:
|
89
|
+
Enabled: true
|
90
|
+
EnforcedStyle: double_quotes
|
91
|
+
|
92
|
+
# Detect hard tabs, no hard tabs.
|
93
|
+
Style/Tab:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
# Blank lines should not have any spaces.
|
97
|
+
Style/TrailingBlankLines:
|
98
|
+
Enabled: true
|
99
|
+
|
100
|
+
# No trailing whitespace.
|
101
|
+
Style/TrailingWhitespace:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
# Use quotes for string literals when they are enough.
|
105
|
+
Style/UnneededPercentQ:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
# Align `end` with the matching keyword or starting expression except for
|
109
|
+
# assignments, where it should be aligned with the LHS.
|
110
|
+
Lint/EndAlignment:
|
111
|
+
Enabled: true
|
112
|
+
AlignWith: variable
|
113
|
+
|
114
|
+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
115
|
+
Lint/RequireParentheses:
|
116
|
+
Enabled: true
|
data/.travis.yml
CHANGED
@@ -1,16 +1,55 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
|
4
|
+
cache:
|
5
|
+
bundler: true
|
6
|
+
|
2
7
|
before_install:
|
3
8
|
- gem install bundler
|
9
|
+
|
4
10
|
rvm:
|
5
11
|
- 1.9.3
|
6
12
|
- 2.0.0
|
13
|
+
- 2.1.9
|
14
|
+
- 2.2.6
|
15
|
+
- 2.3.3
|
16
|
+
- 2.4.0
|
17
|
+
|
7
18
|
gemfile:
|
8
19
|
- Gemfile
|
9
20
|
- gemfiles/Gemfile-4-0-stable
|
21
|
+
- gemfiles/Gemfile-4-1-stable
|
22
|
+
- gemfiles/Gemfile-4-2-stable
|
23
|
+
- gemfiles/Gemfile-5-0-stable
|
10
24
|
- gemfiles/Gemfile-edge
|
25
|
+
|
11
26
|
matrix:
|
12
27
|
allow_failures:
|
13
28
|
- gemfile: gemfiles/Gemfile-edge
|
29
|
+
exclude:
|
30
|
+
- rvm: 1.9.3
|
31
|
+
gemfile: Gemfile
|
32
|
+
- rvm: 2.0.0
|
33
|
+
gemfile: Gemfile
|
34
|
+
- rvm: 2.1.9
|
35
|
+
gemfile: Gemfile
|
36
|
+
- rvm: 1.9.3
|
37
|
+
gemfile: gemfiles/Gemfile-5-0-stable
|
38
|
+
- rvm: 2.0.0
|
39
|
+
gemfile: gemfiles/Gemfile-5-0-stable
|
40
|
+
- rvm: 2.1.9
|
41
|
+
gemfile: gemfiles/Gemfile-5-0-stable
|
42
|
+
- rvm: 1.9.3
|
43
|
+
gemfile: gemfiles/Gemfile-edge
|
44
|
+
- rvm: 2.0.0
|
45
|
+
gemfile: gemfiles/Gemfile-edge
|
46
|
+
- rvm: 2.1.9
|
47
|
+
gemfile: gemfiles/Gemfile-edge
|
48
|
+
- rvm: 2.4.0
|
49
|
+
gemfile: gemfiles/Gemfile-4-0-stable
|
50
|
+
- rvm: 2.4.0
|
51
|
+
gemfile: gemfiles/Gemfile-4-1-stable
|
52
|
+
|
14
53
|
notifications:
|
15
54
|
email: false
|
16
55
|
irc:
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,36 @@
|
|
1
|
-
|
1
|
+
## 1.1.0 (January 23, 2017)
|
2
2
|
|
3
|
-
*
|
3
|
+
* Support dynamic `page_cache_directory` using a Proc, Symbol or callable
|
4
4
|
|
5
|
-
|
5
|
+
*Andrew White*
|
6
6
|
|
7
|
-
*
|
7
|
+
* Support instance level setting of `page_cache_directory`
|
8
8
|
|
9
|
-
|
9
|
+
*Andrew White*
|
10
10
|
|
11
|
-
*
|
11
|
+
* Add support for Rails 5.0 and master
|
12
|
+
|
13
|
+
*Andrew White*
|
14
|
+
|
15
|
+
|
16
|
+
## 1.0.2 (November 15, 2013)
|
17
|
+
|
18
|
+
* Fix load order problem with other gems.
|
19
|
+
|
20
|
+
*Rafael Mendonça França*
|
21
|
+
|
22
|
+
|
23
|
+
## 1.0.1 (October 24, 2013)
|
24
|
+
|
25
|
+
* Add Railtie to set `page_cache_directory` by default to `public` folder.
|
26
|
+
|
27
|
+
Fixes #5.
|
28
|
+
|
29
|
+
*Žiga Vidic*
|
30
|
+
|
31
|
+
|
32
|
+
## 1.0.0 (February 27, 2013)
|
33
|
+
|
34
|
+
* Extract Action Pack - Action Caching from Rails core.
|
35
|
+
|
36
|
+
*Francesco Rodriguez*, *Rafael Mendonça França*, *Michiel Sikkes*
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,14 +3,14 @@ actionpack-page_caching
|
|
3
3
|
|
4
4
|
Static page caching for Action Pack (removed from core in Rails 4.0).
|
5
5
|
|
6
|
-
**NOTE:** It will continue to be officially maintained until Rails 4.1.
|
7
|
-
|
8
6
|
Installation
|
9
7
|
------------
|
10
8
|
|
11
9
|
Add this line to your application's Gemfile:
|
12
10
|
|
13
|
-
|
11
|
+
``` ruby
|
12
|
+
gem "actionpack-page_caching"
|
13
|
+
```
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
@@ -23,7 +23,7 @@ Or install it yourself as:
|
|
23
23
|
Usage
|
24
24
|
-----
|
25
25
|
|
26
|
-
Page caching is an approach to caching where the entire action output
|
26
|
+
Page caching is an approach to caching where the entire action output is
|
27
27
|
stored as a HTML file that the web server can serve without going through
|
28
28
|
Action Pack. This is the fastest way to cache your content as opposed to going
|
29
29
|
dynamically through the process of generating the content. Unfortunately, this
|
@@ -34,13 +34,52 @@ where people log in and manipulate their own data are often less likely candidat
|
|
34
34
|
|
35
35
|
First you need to set `page_cache_directory` in your configuration file:
|
36
36
|
|
37
|
-
|
37
|
+
``` ruby
|
38
|
+
config.action_controller.page_cache_directory = "#{Rails.root}/public/cached_pages"
|
39
|
+
```
|
38
40
|
|
39
|
-
|
41
|
+
The `page_cache_directory` setting can be used with a Proc:
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
class WeblogController < ApplicationController
|
45
|
+
self.page_cache_directory = -> { Rails.root.join("public", request.domain) }
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
a Symbol:
|
40
50
|
|
41
|
-
|
42
|
-
|
51
|
+
``` ruby
|
52
|
+
class WeblogController < ApplicationController
|
53
|
+
self.page_cache_directory = :domain_cache_directory
|
54
|
+
|
55
|
+
private
|
56
|
+
def domain_cache_directory
|
57
|
+
Rails.root.join("public", request.domain)
|
43
58
|
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
or a callable object:
|
63
|
+
|
64
|
+
``` ruby
|
65
|
+
class DomainCacheDirectory
|
66
|
+
def self.call(request)
|
67
|
+
Rails.root.join("public", request.domain)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class WeblogController < ApplicationController
|
72
|
+
self.page_cache_directory = DomainCacheDirectory
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
Specifying which actions to cache is done through the `caches_page` class method:
|
77
|
+
|
78
|
+
``` ruby
|
79
|
+
class WeblogController < ActionController::Base
|
80
|
+
caches_page :show, :new
|
81
|
+
end
|
82
|
+
```
|
44
83
|
|
45
84
|
This will generate cache files such as `weblog/show/5.html` and
|
46
85
|
`weblog/new.html`, which match the URLs used that would normally trigger
|
@@ -54,17 +93,23 @@ in a lazy regeneration approach where the cache is not restored before another
|
|
54
93
|
hit is made against it. The API for doing so mimics the options from `url_for`
|
55
94
|
and friends:
|
56
95
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
96
|
+
``` ruby
|
97
|
+
class WeblogController < ActionController::Base
|
98
|
+
def update
|
99
|
+
List.update(params[:list][:id], params[:list])
|
100
|
+
expire_page action: "show", id: params[:list][:id]
|
101
|
+
redirect_to action: "show", id: params[:list][:id]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
```
|
64
105
|
|
65
106
|
Additionally, you can expire caches using [Sweepers](https://github.com/rails/rails-observers#action-controller-sweeper)
|
66
107
|
that act on changes in the model to determine when a cache is supposed to be expired.
|
67
108
|
|
109
|
+
Finally, configure your web server to serve these static pages when they are present
|
110
|
+
rather than the original files. See the [project wiki][1] for example configurations.
|
111
|
+
[1]: https://github.com/rails/actionpack-page_caching/wiki
|
112
|
+
|
68
113
|
Contributing
|
69
114
|
------------
|
70
115
|
|
@@ -77,5 +122,5 @@ Contributing
|
|
77
122
|
Code Status
|
78
123
|
-----------
|
79
124
|
|
80
|
-
* [](https://travis-ci.org/rails/actionpack-page_caching)
|
126
|
+
* [](https://gemnasium.com/rails/actionpack-page_caching)
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rake/testtask"
|
4
4
|
|
5
5
|
Rake::TestTask.new do |t|
|
6
|
-
t.libs = [
|
7
|
-
t.pattern =
|
8
|
-
t.ruby_opts = [
|
6
|
+
t.libs = ["test"]
|
7
|
+
t.pattern = "test/**/*_test.rb"
|
8
|
+
t.ruby_opts = ["-w"]
|
9
9
|
end
|
10
10
|
|
11
11
|
task default: :test
|
@@ -1,20 +1,21 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
Gem::Specification.new do |gem|
|
4
|
-
gem.name =
|
5
|
-
gem.version =
|
6
|
-
gem.author =
|
7
|
-
gem.email =
|
8
|
-
gem.description =
|
9
|
-
gem.summary =
|
10
|
-
gem.homepage =
|
2
|
+
gem.name = "actionpack-page_caching"
|
3
|
+
gem.version = "1.1.0"
|
4
|
+
gem.author = "David Heinemeier Hansson"
|
5
|
+
gem.email = "david@loudthinking.com"
|
6
|
+
gem.description = "Static page caching for Action Pack (removed from core in Rails 4.0)"
|
7
|
+
gem.summary = "Static page caching for Action Pack (removed from core in Rails 4.0)"
|
8
|
+
gem.homepage = "https://github.com/rails/actionpack-page_caching"
|
9
|
+
gem.license = "MIT"
|
11
10
|
|
11
|
+
gem.required_ruby_version = '>= 1.9.3'
|
12
12
|
gem.files = `git ls-files`.split($/)
|
13
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
-
gem.require_paths = [
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.license = 'MIT'
|
16
17
|
|
17
|
-
gem.add_dependency
|
18
|
+
gem.add_dependency "actionpack", ">= 4.0.0", "< 6"
|
18
19
|
|
19
|
-
gem.add_development_dependency
|
20
|
+
gem.add_development_dependency "mocha"
|
20
21
|
end
|
data/gemfiles/Gemfile-4-0-stable
CHANGED