middleman-cdn 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -7
- data/README.md +4 -2
- data/lib/middleman-cdn/cdns/cloudflare.rb +1 -1
- data/lib/middleman-cdn/commands.rb +11 -2
- data/lib/middleman-cdn/version.rb +1 -1
- data/middleman-cdn.gemspec +3 -3
- data/spec/lib/middleman-cdn/cdns/cloudflare_spec.rb +3 -3
- data/spec/lib/middleman-cdn/commands_spec.rb +9 -8
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316430650f5872061c138b58a8762b27a35550e2
|
4
|
+
data.tar.gz: c6899ae2f56b98123c61cac84d77fdb4f4f866d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4961cbebfbe185e75ec74612a4a8992f88cbda4a4814a1577ab5fdc48c31c04f80ab58ad3ebd1cbb456a13553343ddbb88ae7909f31997d8828f9301e2d35e11
|
7
|
+
data.tar.gz: 3062f33bcad19b95088ffe2e161d7abd45994d62c1b0d9427f9e68532defa139367035c765d8f15f94a70d96890778e664a5faeea504d242159fa8f06ad92d03
|
data/.travis.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
|
-
- 2.2
|
5
|
-
- 2.3
|
6
|
-
- 2.4
|
4
|
+
- 2.2
|
5
|
+
- 2.3
|
6
|
+
- 2.4
|
7
7
|
before_install:
|
8
8
|
- gem update --system
|
9
9
|
- gem install bundler
|
@@ -15,7 +15,3 @@ gemfile:
|
|
15
15
|
- gemfiles/middleman_4.1.gemfile
|
16
16
|
- gemfiles/middleman_4.2.gemfile
|
17
17
|
- gemfiles/middleman_master.gemfile
|
18
|
-
matrix:
|
19
|
-
allow_failures:
|
20
|
-
- rvm: 2.4.0
|
21
|
-
gemfile: gemfiles/middleman_4.1.gemfile
|
data/README.md
CHANGED
@@ -94,8 +94,10 @@ It's better to always invalidate only the files you need. If you're using
|
|
94
94
|
generate fingerprinted CSS, JS and images, then you should never need to
|
95
95
|
invalidate them.
|
96
96
|
|
97
|
-
Note: Directories containing `index.html` files are automatically included
|
98
|
-
|
97
|
+
Note: Directories containing `index.html` files are automatically included when
|
98
|
+
their respective `index.html` is included in the filter. Both the slashed and
|
99
|
+
non-slashed version of the directory are invalidated. e.g. The file
|
100
|
+
`/blog/index.html` will also invalidate `/blog/` and `/blog`.
|
99
101
|
|
100
102
|
Alternatively: If you're using `middleman-s3_sync` you can hook middleman-cdn into
|
101
103
|
it's build process. See the [instructions here](#invalidating-with-middleman-s3_sync).
|
@@ -39,7 +39,7 @@ module Middleman
|
|
39
39
|
raise
|
40
40
|
end
|
41
41
|
|
42
|
-
cloudflare = ::
|
42
|
+
cloudflare = ::Cloudflare::connection(options[:client_api_key], options[:email])
|
43
43
|
if all || (options[:invalidate_zone_for_many_files] && files.count > INVALIDATE_ZONE_THRESHOLD)
|
44
44
|
begin
|
45
45
|
say_status("Invalidating zone #{options[:zone]}... ", newline: false)
|
@@ -119,15 +119,24 @@ end
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def normalize_files(files)
|
122
|
+
normalized_files = []
|
123
|
+
|
122
124
|
# Add directories of index.html files since they have to be
|
123
125
|
# invalidated as well if :directory_indexes is active
|
124
126
|
files.each do |file|
|
127
|
+
normalized_files << file
|
128
|
+
|
129
|
+
# For /dir/index.html add /dir/
|
125
130
|
file_dir = file.sub(/\bindex\.html\z/, '')
|
126
|
-
|
131
|
+
normalized_files << file_dir if file_dir != file
|
132
|
+
|
133
|
+
# For /dir/index.html add /dir
|
134
|
+
file_dir_no_slash = file.sub(/\/index\.html\z/, '')
|
135
|
+
normalized_files << file_dir_no_slash if file_dir_no_slash != file
|
127
136
|
end
|
128
137
|
|
129
138
|
# Add leading slash
|
130
|
-
|
139
|
+
normalized_files.map { |f| f.start_with?('/') ? f : "/#{f}" }
|
131
140
|
end
|
132
141
|
|
133
142
|
Base.register(self, 'cdn_invalidate', 'cdn_invalidate [options]', 'Invalidate CDN')
|
data/middleman-cdn.gemspec
CHANGED
@@ -17,11 +17,11 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency 'fog-aws', '~> 1.4'
|
20
|
-
s.add_dependency 'cloudflare', '~>
|
20
|
+
s.add_dependency 'cloudflare', '~> 3.0'
|
21
21
|
s.add_dependency 'fastly', '~> 1.1'
|
22
22
|
s.add_dependency 'maxcdn', '~> 0.1'
|
23
23
|
s.add_dependency 'ansi', '~> 1.5'
|
24
|
-
s.add_dependency 'activesupport', '
|
24
|
+
s.add_dependency 'activesupport', '>= 4.1'
|
25
25
|
s.add_dependency 'httparty', '~> 0.13'
|
26
26
|
|
27
27
|
s.add_development_dependency 'rake', '~> 0.9'
|
@@ -29,5 +29,5 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_development_dependency 'coveralls', '~> 0.7'
|
30
30
|
s.add_development_dependency 'appraisal', '~> 2.1'
|
31
31
|
|
32
|
-
s.add_dependency 'middleman', '>= 3.
|
32
|
+
s.add_dependency 'middleman', '>= 3.2'
|
33
33
|
end
|
@@ -52,7 +52,7 @@ describe Middleman::Cli::CloudFlareCDN do
|
|
52
52
|
|
53
53
|
before do
|
54
54
|
allow(double_cloudflare).to receive(:zone_file_purge)
|
55
|
-
allow(::
|
55
|
+
allow(::Cloudflare).to receive(:connection).and_return(double_cloudflare)
|
56
56
|
end
|
57
57
|
|
58
58
|
let(:files) { (1..50).map { |i| "/test/file_#{i}.txt" } }
|
@@ -69,7 +69,7 @@ describe Middleman::Cli::CloudFlareCDN do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should connect to cloudflare with credentails" do
|
72
|
-
expect(::
|
72
|
+
expect(::Cloudflare).to receive(:connection).with("000000000000000000000", "test@example.com")
|
73
73
|
subject.invalidate(options, files)
|
74
74
|
end
|
75
75
|
|
@@ -166,7 +166,7 @@ describe Middleman::Cli::CloudFlareCDN do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should connect to cloudflare with environment variable credentails" do
|
169
|
-
expect(::
|
169
|
+
expect(::Cloudflare).to receive(:connection).with("111111111111111111111", "test-env@example.com")
|
170
170
|
subject.invalidate(options, files)
|
171
171
|
end
|
172
172
|
|
@@ -26,8 +26,9 @@ describe Middleman::Cli::CDN do
|
|
26
26
|
describe '#cdn_invalidate' do
|
27
27
|
before do
|
28
28
|
allow(Dir).to receive(:chdir).with(anything) { |path, &block| block.call }
|
29
|
-
allow(Dir).to receive(:glob).with('**/*', File::FNM_DOTMATCH).and_return([".", "index.html", "image.png"])
|
29
|
+
allow(Dir).to receive(:glob).with('**/*', File::FNM_DOTMATCH).and_return([".", "index.html", "image.png", "blog/index.html"])
|
30
30
|
allow(File).to receive(:directory?).with(".").and_return(true)
|
31
|
+
allow(File).to receive(:directory?).with("blog/index.html").and_return(false)
|
31
32
|
allow(File).to receive(:directory?).with("index.html").and_return(false)
|
32
33
|
allow(File).to receive(:directory?).with("image.png").and_return(false)
|
33
34
|
end
|
@@ -57,7 +58,7 @@ describe Middleman::Cli::CDN do
|
|
57
58
|
end
|
58
59
|
|
59
60
|
it "should invalidate the files with only cloudflare" do
|
60
|
-
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/image.png", "/"], all: true)
|
61
|
+
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/", "/image.png", "/blog/index.html", "/blog/", "/blog"], all: true)
|
61
62
|
expect_any_instance_of(::Middleman::Cli::CloudFrontCDN).to_not receive(:invalidate)
|
62
63
|
expect_any_instance_of(::Middleman::Cli::FastlyCDN).to_not receive(:invalidate)
|
63
64
|
subject.cdn_invalidate(options)
|
@@ -75,9 +76,9 @@ describe Middleman::Cli::CDN do
|
|
75
76
|
end
|
76
77
|
|
77
78
|
it "should invalidate the files with all cdns" do
|
78
|
-
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/image.png", "/"], all: true)
|
79
|
-
expect_any_instance_of(::Middleman::Cli::CloudFrontCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/image.png", "/"], all: true)
|
80
|
-
expect_any_instance_of(::Middleman::Cli::FastlyCDN).to receive(:invalidate).with(options.fastly, ["/index.html", "/image.png", "/"], all: true)
|
79
|
+
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/", "/image.png", "/blog/index.html", "/blog/", "/blog"], all: true)
|
80
|
+
expect_any_instance_of(::Middleman::Cli::CloudFrontCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/", "/image.png", "/blog/index.html", "/blog/", "/blog"], all: true)
|
81
|
+
expect_any_instance_of(::Middleman::Cli::FastlyCDN).to receive(:invalidate).with(options.fastly, ["/index.html", "/", "/image.png", "/blog/index.html", "/blog/", "/blog"], all: true)
|
81
82
|
subject.cdn_invalidate(options)
|
82
83
|
end
|
83
84
|
end
|
@@ -94,9 +95,9 @@ describe Middleman::Cli::CDN do
|
|
94
95
|
end
|
95
96
|
|
96
97
|
it "should invalidate the files with all cdns" do
|
97
|
-
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/"], all: false)
|
98
|
-
expect_any_instance_of(::Middleman::Cli::CloudFrontCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/"], all: false)
|
99
|
-
expect_any_instance_of(::Middleman::Cli::FastlyCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/"], all: false)
|
98
|
+
expect_any_instance_of(::Middleman::Cli::CloudFlareCDN).to receive(:invalidate).with(options.cloudflare, ["/index.html", "/", "/blog/index.html", "/blog/", "/blog"], all: false)
|
99
|
+
expect_any_instance_of(::Middleman::Cli::CloudFrontCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/", "/blog/index.html", "/blog/", "/blog"], all: false)
|
100
|
+
expect_any_instance_of(::Middleman::Cli::FastlyCDN).to receive(:invalidate).with(options.cloudfront, ["/index.html", "/", "/blog/index.html", "/blog/", "/blog"], all: false)
|
100
101
|
subject.cdn_invalidate(options)
|
101
102
|
end
|
102
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-cdn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leigh McCulloch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-aws
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: fastly
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '4.1'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '4.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '3.
|
173
|
+
version: '3.2'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '3.
|
180
|
+
version: '3.2'
|
181
181
|
description: Invalidate a specific set of files in your CloudFlare, AWS CloudFront,
|
182
182
|
Rackspace, Fastly, or MaxCDN cache
|
183
183
|
email:
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
245
|
rubyforge_project:
|
246
|
-
rubygems_version: 2.
|
246
|
+
rubygems_version: 2.5.2.1
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
249
|
summary: Invalidate CloudFlare, AWS CloudFront, Rackspace, Fastly, or MaxCDN cache
|