actionpack-page_caching 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack-page_caching might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 781564cc88b5d47624ce552331dbbf58634f5891
4
- data.tar.gz: f7dfd38f06481f38eef9f7630258dae673ecd881
3
+ metadata.gz: bcc463b295ac09cfa6b0ca15557d7e00da2bf92b
4
+ data.tar.gz: 1ca39e53842cb9446214249e47cfe791596e763e
5
5
  SHA512:
6
- metadata.gz: 96c15cb3d1b344f31655c04b265ba1c3fb6484726880af6a36165eefcc3dfbbff89851fd47de410429c2a3c1e75e0baa038ef23ecb3b0fbf75c69ed7e9c3c708
7
- data.tar.gz: d005f7998314f2311492592d958b78397934de01bec68f16806ef5b99ee122e426007bdaecbad7a5d71e2309b53fe56d3bad0b7ce0ca7395fb153cc462082826
6
+ metadata.gz: cd19ec3f9214460795607de16e4d66769b7621cac4caa329ada8ec810b9414a6f1e5280b8132d683adcba70343b85750356c8d0d3d017f7d98ed199384ad1b14
7
+ data.tar.gz: afa5b80f7c9ce7c54e284fa35bc3c484d7c0552aff051999dd668edd99827059570b019a01e00da544d23c68a78e9427354f68e5b36981221fc808f38f283912
@@ -0,0 +1,7 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+
5
+ ratings:
6
+ paths:
7
+ - "**.rb"
data/.gitignore CHANGED
@@ -1,17 +1,5 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
1
+ .ruby-version
6
2
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
3
+ gemfiles/*.lock
4
+ pkg/*
15
5
  test/tmp
16
- test/version_tmp
17
- tmp
@@ -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
@@ -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:
@@ -1,11 +1,36 @@
1
- # 1.0.2
1
+ ## 1.1.0 (January 23, 2017)
2
2
 
3
- * Fix load order problem with other gems.
3
+ * Support dynamic `page_cache_directory` using a Proc, Symbol or callable
4
4
 
5
- # 1.0.1
5
+ *Andrew White*
6
6
 
7
- * Add Railtie to set `page_cache_directory` by default to `public` folder. (Fixes #5)
7
+ * Support instance level setting of `page_cache_directory`
8
8
 
9
- # 1.0.0
9
+ *Andrew White*
10
10
 
11
- * First Release
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
@@ -1,5 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'rails'
5
+ gem "rails"
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
- gem 'actionpack-page_caching'
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 of is
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
- config.action_controller.page_cache_directory = "#{Rails.root.to_s}/public/deploy"
37
+ ``` ruby
38
+ config.action_controller.page_cache_directory = "#{Rails.root}/public/cached_pages"
39
+ ```
38
40
 
39
- Specifying which actions to cache is done through the `caches_page` class method:
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
- class WeblogController < ActionController::Base
42
- caches_page :show, :new
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
- class WeblogController < ActionController::Base
58
- def update
59
- List.update(params[:list][:id], params[:list])
60
- expire_page action: 'show', id: params[:list][:id]
61
- redirect_to action: 'show', id: params[:list][:id]
62
- end
63
- end
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
- * [![Build Status](https://travis-ci.org/rails/actionpack-page_caching.png?branch=master)](https://travis-ci.org/rails/page_caching)
81
- * [![Dependency Status](https://gemnasium.com/rails/actionpack-page_caching.png)](https://gemnasium.com/rails/actionpack-page_caching)
125
+ * [![Build Status](https://travis-ci.org/rails/actionpack-page_caching.svg?branch=master)](https://travis-ci.org/rails/actionpack-page_caching)
126
+ * [![Dependency Status](https://gemnasium.com/rails/actionpack-page_caching.svg)](https://gemnasium.com/rails/actionpack-page_caching)
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rake/testtask'
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
4
 
5
5
  Rake::TestTask.new do |t|
6
- t.libs = ['test']
7
- t.pattern = 'test/**/*_test.rb'
8
- t.ruby_opts = ['-w']
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 = 'actionpack-page_caching'
5
- gem.version = '1.0.2'
6
- gem.author = 'David Heinemeier Hansson'
7
- gem.email = 'david@loudthinking.com'
8
- gem.description = 'Static page caching for Action Pack (removed from core in Rails 4.0)'
9
- gem.summary = 'Static page caching for Action Pack (removed from core in Rails 4.0)'
10
- gem.homepage = 'https://github.com/rails/actionpack-page_caching'
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 = ['lib']
15
+ gem.require_paths = ["lib"]
16
+ gem.license = 'MIT'
16
17
 
17
- gem.add_dependency 'actionpack', '>= 4.0.0', '< 5'
18
+ gem.add_dependency "actionpack", ">= 4.0.0", "< 6"
18
19
 
19
- gem.add_development_dependency 'mocha'
20
+ gem.add_development_dependency "mocha"
20
21
  end
@@ -1,5 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gemspec path: '..'
3
+ gemspec path: ".."
4
4
 
5
- gem 'rails', github: 'rails/rails', branch: '4-0-stable'
5
+ gem "rails", github: "rails/rails", branch: "4-0-stable"
6
+ gem "mime-types", "< 3"