actionpack-action_caching 1.1.1 → 1.2.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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +7 -0
- data/.gitignore +3 -15
- data/.rubocop.yml +116 -0
- data/.travis.yml +40 -1
- data/CHANGELOG.md +34 -2
- data/Gemfile +2 -2
- data/README.md +39 -33
- data/Rakefile +5 -5
- data/actionpack-action_caching.gemspec +14 -15
- 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/action_caching.rb +1 -1
- data/lib/action_controller/caching/actions.rb +53 -24
- data/lib/actionpack/action_caching.rb +1 -1
- data/lib/actionpack/action_caching/railtie.rb +3 -3
- data/test/abstract_unit.rb +8 -37
- data/test/caching_test.rb +487 -122
- data/test/fixtures/layouts/talk_from_action.html.erb +2 -0
- metadata +17 -12
- data/test/fixtures/layouts/talk_from_action.erb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c3e6a065ee870841cd63083ad4fbe729a3f3d39
|
4
|
+
data.tar.gz: 7ec1ff92fc66365d06709ff8158687922aae7dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c48324f7e2c76ddc22e3b9799bef687f2de43d122c319cc62df0fa5539b3a42209f24cb88847e8dd1168bf6a710f951179359de51d8570d63115211efc87a97e
|
7
|
+
data.tar.gz: e9c4f0b4f373207d16cc27f486c5747661f70d4adad18d21287126e3072e3a55b1bdf83296893b5ea85d331907d578f44e7979dc9257978e3d97f87991d96a83
|
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
|
-
- gemfiles/Gemfile-edge
|
10
20
|
- gemfiles/Gemfile-4-0-stable
|
21
|
+
- gemfiles/Gemfile-4-1-stable
|
22
|
+
- gemfiles/Gemfile-4-2-stable
|
23
|
+
- gemfiles/Gemfile-5-0-stable
|
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,10 +1,41 @@
|
|
1
|
-
## 1.
|
1
|
+
## 1.2.0 (January 23, 2014)
|
2
|
+
|
3
|
+
* Support proc options with zero arguments
|
4
|
+
|
5
|
+
Fixes #40.
|
6
|
+
|
7
|
+
*Andrew White*
|
8
|
+
|
9
|
+
* The options `:layout` and `:cache_path` now behave the same when
|
10
|
+
passed a `Symbol`, `Proc` or object that responds to call.
|
11
|
+
|
12
|
+
*Andrew White*
|
13
|
+
|
14
|
+
* Respect `Accept` header when caching actions
|
15
|
+
|
16
|
+
Fixes #18.
|
17
|
+
|
18
|
+
*Andrew White*
|
19
|
+
|
20
|
+
* Support Rails 4.0, 4.1, 4.2, 5.0 and edge
|
21
|
+
|
22
|
+
*Eileen Uchitelle*, *Andrew White*
|
23
|
+
|
24
|
+
* Call `to_s` on the extension as it may be a symbol
|
25
|
+
|
26
|
+
Fixes #10.
|
27
|
+
|
28
|
+
*Andrew White*
|
29
|
+
|
30
|
+
|
31
|
+
## 1.1.1 (January 2, 2014)
|
2
32
|
|
3
33
|
* Fix load order problem with other gems
|
4
34
|
|
5
35
|
*Andrew White*
|
6
36
|
|
7
|
-
|
37
|
+
|
38
|
+
## 1.1.0 (November 1, 2013)
|
8
39
|
|
9
40
|
* Allow to use non-proc object in `cache_path` option. You can pass an object that
|
10
41
|
responds to a `call` method.
|
@@ -24,6 +55,7 @@
|
|
24
55
|
|
25
56
|
*Piotr Niełacny*
|
26
57
|
|
58
|
+
|
27
59
|
## 1.0.0 (February 28, 2013)
|
28
60
|
|
29
61
|
* Extract Action Pack - Action Caching from Rails core.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,14 +3,12 @@ actionpack-action_caching
|
|
3
3
|
|
4
4
|
Action 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
|
-
gem
|
11
|
+
gem "actionpack-action_caching"
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
@@ -31,7 +29,7 @@ authentication and other restrictions on whether someone is allowed
|
|
31
29
|
to execute such action.
|
32
30
|
|
33
31
|
class ListsController < ApplicationController
|
34
|
-
|
32
|
+
before_action :authenticate, except: :public
|
35
33
|
|
36
34
|
caches_page :public
|
37
35
|
caches_action :index, :show
|
@@ -56,17 +54,18 @@ Different representations of the same resource, e.g.
|
|
56
54
|
`http://david.example.com/lists.xml`
|
57
55
|
are treated like separate requests and so are cached separately.
|
58
56
|
Keep in mind when expiring an action cache that
|
59
|
-
`action:
|
60
|
-
`action:
|
57
|
+
`action: "lists"` is not the same as
|
58
|
+
`action: "list", format: :xml`.
|
61
59
|
|
62
60
|
You can modify the default action cache path by passing a
|
63
61
|
`:cache_path` option. This will be passed directly to
|
64
62
|
`ActionCachePath.new`. This is handy for actions with
|
65
63
|
multiple possible routes that should be cached differently. If a
|
66
|
-
|
64
|
+
proc (or an object that responds to `to_proc`) is given, it is
|
65
|
+
called with the current controller instance.
|
67
66
|
|
68
|
-
And you can also use `:if` (or `:unless`) to
|
69
|
-
|
67
|
+
And you can also use `:if` (or `:unless`) to control when the action
|
68
|
+
should be cached, similar to how you use them with `before_action`.
|
70
69
|
|
71
70
|
As of Rails 3.0, you can also pass `:expires_in` with a time
|
72
71
|
interval (in seconds) to schedule expiration of the cached item.
|
@@ -74,38 +73,45 @@ interval (in seconds) to schedule expiration of the cached item.
|
|
74
73
|
The following example depicts some of the points made above:
|
75
74
|
|
76
75
|
class ListsController < ApplicationController
|
77
|
-
|
76
|
+
before_action :authenticate, except: :public
|
77
|
+
|
78
|
+
# simple fragment cache
|
79
|
+
caches_action :current
|
80
|
+
|
81
|
+
# expire cache after an hour
|
82
|
+
caches_action :archived, expires_in: 1.hour
|
78
83
|
|
79
|
-
|
84
|
+
# cache unless it's a JSON request
|
85
|
+
caches_action :index, unless: -> { request.format.json? }
|
80
86
|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
87
|
+
# custom cache path
|
88
|
+
caches_action :show, cache_path: { project: 1 }
|
84
89
|
|
85
|
-
|
86
|
-
|
90
|
+
# custom cache path with a proc
|
91
|
+
caches_action :history, cache_path: -> { request.domain }
|
87
92
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
# custom cache path with a symbol
|
94
|
+
caches_action :feed, cache_path: :user_cache_path
|
95
|
+
|
96
|
+
protected
|
97
|
+
def user_cache_path
|
98
|
+
if params[:user_id]
|
99
|
+
user_list_url(params[:user_id], params[:id])
|
100
|
+
else
|
101
|
+
list_url(params[:id])
|
102
|
+
end
|
93
103
|
end
|
94
|
-
end
|
95
104
|
end
|
96
105
|
|
97
106
|
If you pass `layout: false`, it will only cache your action
|
98
107
|
content. That's useful when your layout has dynamic information.
|
99
108
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
The `:format` parameter is taken into account though. The safest
|
108
|
-
way to cache by MIME type is to pass the format in the route.
|
109
|
+
Note: Both the `:format` param and the `Accept` header are taken
|
110
|
+
into account when caching the fragment with the `:format` having
|
111
|
+
precedence. For backwards compatibility when the `Accept` header
|
112
|
+
indicates a HTML request the fragment is stored without the
|
113
|
+
extension but if an explicit `"html"` is passed in `:format` then
|
114
|
+
that _is_ used for storing the fragment.
|
109
115
|
|
110
116
|
Contributing
|
111
117
|
------------
|
@@ -119,5 +125,5 @@ Contributing
|
|
119
125
|
Code Status
|
120
126
|
-----------
|
121
127
|
|
122
|
-
* [](https://travis-ci.org/rails/actionpack-action_caching)
|
129
|
+
* [](https://gemnasium.com/rails/actionpack-action_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,22 +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-action_caching"
|
3
|
+
gem.version = "1.2.0"
|
4
|
+
gem.author = "David Heinemeier Hansson"
|
5
|
+
gem.email = "david@loudthinking.com"
|
6
|
+
gem.description = "Action caching for Action Pack (removed from core in Rails 4.0)"
|
7
|
+
gem.summary = "Action caching for Action Pack (removed from core in Rails 4.0)"
|
8
|
+
gem.homepage = "https://github.com/rails/actionpack-action_caching"
|
11
9
|
|
10
|
+
gem.required_ruby_version = ">= 1.9.3"
|
12
11
|
gem.files = `git ls-files`.split($/)
|
13
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
14
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
-
gem.require_paths = [
|
16
|
-
gem.license =
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.license = "MIT"
|
17
16
|
|
18
|
-
gem.add_dependency
|
17
|
+
gem.add_dependency "actionpack", ">= 4.0.0", "< 6"
|
19
18
|
|
20
|
-
gem.add_development_dependency
|
21
|
-
gem.add_development_dependency
|
19
|
+
gem.add_development_dependency "mocha"
|
20
|
+
gem.add_development_dependency "activerecord", ">= 4.0.0", "< 6"
|
22
21
|
end
|