grape-cache_control 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16e68a4e78f8eaa8c8f3694a9daa224b67e5cbee
4
- data.tar.gz: c9272e37b6ccfa43a78d174cf32a0b685a0d793d
3
+ metadata.gz: df369824a78246d6fe3304d1df3b3fdf29b37772
4
+ data.tar.gz: 5a2b2a61b99c48192b29621e41e8949d1f8d70ae
5
5
  SHA512:
6
- metadata.gz: 70e5099b638f22ce51779efe785ab8d18c71c7ed4c60d43e73db7aa96a4e118025127e4fa25ece5463ae91327574ecebe8bad5e210aa81773664bcf784045303
7
- data.tar.gz: 2c8456850b8fb00712070d8abce3e973002380bdd487753e561babc464bb78898997daea39cee89477a8bbd13145d1c046bbdcab10f9896cf4dff110fa23fc04
6
+ metadata.gz: 5403c032382bc8c7740bbc5813a36f5a97d5000098269cf6625cf3261478b453845545176b60ea346404996e5c556fb5e4f19c704f5fe5cc034f14931b3cce5f
7
+ data.tar.gz: a09a39428126304de3df5af07b39f2e040cf8af2de107bfb7e08b95967134093cc5a4241aff402b4fcfc2ef717991b5e9bb606edd296c6c021119cfd747a7d50
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/README.md CHANGED
@@ -18,6 +18,12 @@ require 'grape/cache_control'
18
18
  # Cache-Control:public,max-age=900
19
19
  cache_control :public, max_age: 900
20
20
 
21
+ # Cache-Control:public,max-age=900,stale-while-revalidate=1600
22
+ cache_control :public, max_age: 900, stale_while_revalidate: 1600
23
+
24
+ # Cache-Control:public,max-age=900,stale-while-error=1600
25
+ cache_control :public, max_age: 900, stale_while_error: 1600
26
+
21
27
  # Cache-Control:public,no-store,max-age=900,s-maxage=86400
22
28
  cache_control :public, :no_store, max_age: 900, s_maxage:86400
23
29
 
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ end
15
15
  begin
16
16
  require 'rubocop/rake_task'
17
17
  desc 'Run rubocop'
18
- Rubocop::RakeTask.new(:rubocop)
18
+ RuboCop::RakeTask.new(:rubocop)
19
19
  rescue LoadError
20
20
  end
21
21
 
@@ -9,8 +9,9 @@ module Grape
9
9
  CACHE_CONTROL = 'Cache-Control'.freeze
10
10
  EXPIRES = 'Expires'.freeze
11
11
  TRUE = 'true'.freeze
12
- SETTABLE_DIRECTIVES = [:max_age, :s_maxage].freeze
13
- TRUTHY_DIRECTIVES = [:public, :private, :no_cache, :no_store, :no_transform, :must_revalidate, :proxy_revalidate].freeze
12
+ SETTABLE_DIRECTIVES = [:max_age, :s_maxage, :stale_while_revalidate, :stale_while_error].freeze
13
+ TRUTHY_DIRECTIVES = [:public, :private, :no_cache, :no_store, :no_transform,
14
+ :must_revalidate, :proxy_revalidate].freeze
14
15
  ALL_DIRECTIVES = (TRUTHY_DIRECTIVES | SETTABLE_DIRECTIVES).freeze
15
16
 
16
17
  ALL_DIRECTIVES.each do |d|
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module CacheControl
3
- VERSION = '1.0.0' unless defined?(Grape::CacheControl::VERSION)
3
+ VERSION = '1.0.1' unless defined?(Grape::CacheControl::VERSION)
4
4
  end
5
5
  end
@@ -66,6 +66,23 @@ describe Grape::CacheControl do
66
66
  expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'max-age=60')
67
67
  end
68
68
 
69
+ it 'supports stale-while-revalidate' do
70
+ subject.get('/stale_blueberries') do
71
+ cache_control :public, stale_while_revalidate: 120
72
+ end
73
+
74
+ get 'stale_blueberries'
75
+ expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'stale-while-revalidate=120')
76
+ end
77
+
78
+ it 'supports stale-while-error' do
79
+ subject.get('/error_blueberries') do
80
+ cache_control :public, stale_while_error: 120
81
+ end
82
+
83
+ get 'error_blueberries'
84
+ expect(last_response.headers['Cache-Control'].split(', ')).to include('public', 'stale-while-error=120')
85
+ end
69
86
  end
70
87
 
71
88
  describe 'expires' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-cache_control
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Freeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-09 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".document"
119
119
  - ".gitignore"
120
+ - ".rspec"
120
121
  - ".rubocop.yml"
121
122
  - ".travis.yml"
122
123
  - ".yardopts"
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 2.2.2
161
+ rubygems_version: 2.4.5
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Cache-Control and Expires helpers for Grape
@@ -168,3 +169,4 @@ test_files:
168
169
  - spec/support/rack-test.rb
169
170
  - spec/support/timecop.rb
170
171
  - spec/unit/grape/cache_control_spec.rb
172
+ has_rdoc: