middleman-s3_sync 3.3.6 → 3.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleman/s3_sync/caching_policy.rb +1 -1
- data/lib/middleman/s3_sync/version.rb +1 -1
- data/spec/caching_policy_spec.rb +76 -58
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14f4fb3014e030baf26085c24f89a852c15f264
|
4
|
+
data.tar.gz: b8c70ecb06640c69606de373237584b51951d9dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c203dd97741209ceedf3de39354f2bcb8c1d4e00b65bc09f4db4aba26479a027a4e67e0e8c69ea4b08523011ea3ba4ee8319c59a77362bea836b81682004b2c4
|
7
|
+
data.tar.gz: 984fba641f37c53cf8c5da14e0b5a1fa2e0044cdb7fb5da997b010772bb58fc3f3a2061ef76afee11597d7d2117a7884593af271acd399907863dd7e36447398
|
@@ -8,7 +8,7 @@ module Middleman
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def caching_policy_for(content_type)
|
11
|
-
caching_policies.fetch(content_type.to_s, caching_policies[:default])
|
11
|
+
caching_policies.fetch(content_type.to_s.split(';').first.strip, caching_policies[:default])
|
12
12
|
end
|
13
13
|
|
14
14
|
def default_caching_policy
|
data/spec/caching_policy_spec.rb
CHANGED
@@ -2,79 +2,97 @@ require 'spec_helper'
|
|
2
2
|
require 'middleman/s3_sync/caching_policy'
|
3
3
|
|
4
4
|
describe Middleman::S3Sync::BrowserCachePolicy do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
context "building the policy" do
|
6
|
+
let(:options) { Hash.new }
|
7
|
+
subject(:policy) { Middleman::S3Sync::BrowserCachePolicy.new(options) }
|
8
|
+
|
9
|
+
it "should be blank" do
|
10
|
+
policy.should_not be_nil
|
11
|
+
|
12
|
+
policy.to_s.should_not =~ /max-age=/
|
13
|
+
policy.to_s.should_not =~ /s-maxage=/
|
14
|
+
policy.to_s.should_not =~ /public/
|
15
|
+
policy.to_s.should_not =~ /private/
|
16
|
+
policy.to_s.should_not =~ /no-cache/
|
17
|
+
policy.to_s.should_not =~ /no-store/
|
18
|
+
policy.to_s.should_not =~ /must-revalidate/
|
19
|
+
policy.to_s.should_not =~ /proxy-revalidate/
|
20
|
+
policy.expires.should be_nil
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
context "setting max-age" do
|
24
|
+
let(:options) { { max_age: 300 } }
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
its(:to_s) { should =~ /max-age=300/ }
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
context "setting s-maxage" do
|
30
|
+
let(:options) { { s_maxage: 300 } }
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
its(:to_s) { should =~ /s-maxage=300/ }
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
context "set public flag" do
|
36
|
+
let(:options) { { public: true } }
|
37
|
+
its(:to_s) { should =~ /public/ }
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
context "it should set the private flag if it is set to true" do
|
41
|
+
let(:options) { { private: true } }
|
42
|
+
its(:to_s) { should =~ /private/ }
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
context "it should set the no-cache flag when set property" do
|
46
|
+
let(:options) { { no_cache: true }}
|
47
|
+
its(:to_s) { should =~ /no-cache/ }
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
context "setting the no-store flag" do
|
51
|
+
let(:options) { { no_store: true } }
|
52
|
+
its(:to_s) { should =~ /no-store/ }
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
context "setting the must-revalidate policy" do
|
56
|
+
let(:options) { { must_revalidate: true } }
|
57
|
+
its(:to_s) { should =~ /must-revalidate/ }
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
context "setting the proxy-revalidate policy" do
|
61
|
+
let(:options) { { proxy_revalidate: true } }
|
62
|
+
its(:to_s) { should =~ /proxy-revalidate/ }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "divide caching policiies with a comma and a space" do
|
66
|
+
let(:options) { { :max_age => 300, :public => true } }
|
63
67
|
|
64
|
-
|
65
|
-
|
68
|
+
it "splits policies eith commans and spaces" do
|
69
|
+
policies = policy.to_s.split(/, /)
|
70
|
+
policies.length.should == 2
|
71
|
+
policies.first.should == 'max-age=300'
|
72
|
+
policies.last.should == 'public'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "set the expiration date" do
|
77
|
+
let(:options) { { expires: 1.years.from_now } }
|
66
78
|
|
67
|
-
|
68
|
-
policies = policy.to_s.split(/, /)
|
69
|
-
policies.length.should == 2
|
70
|
-
policies.first.should == 'max-age=300'
|
71
|
-
policies.last.should == 'public'
|
79
|
+
its(:expires) { should == CGI.rfc1123_date(1.year.from_now )}
|
72
80
|
end
|
73
81
|
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "Storing and retrieving policies" do
|
85
|
+
class CachingPolicy
|
86
|
+
include Middleman::S3Sync::CachingPolicy
|
87
|
+
end
|
88
|
+
|
89
|
+
let(:caching_policy) { CachingPolicy.new }
|
90
|
+
let(:policy) { caching_policy.caching_policy_for("text/html; charset=utf-8") }
|
74
91
|
|
75
|
-
|
76
|
-
|
92
|
+
it "finds the policies by the mime-type excluding the parameters" do
|
93
|
+
caching_policy.add_caching_policy("text/html", max_age: 300)
|
77
94
|
|
78
|
-
|
95
|
+
expect(policy).to_not be_nil
|
96
|
+
expect(policy.policies.max_age).to eq(300)
|
79
97
|
end
|
80
98
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-s3_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederic Jean
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: middleman-core
|