middleman-cloudfront 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +3 -0
- data/Guardfile +9 -0
- data/Rakefile +5 -3
- data/lib/middleman-cloudfront/commands.rb +18 -15
- data/lib/middleman-cloudfront/pkg-info.rb +1 -1
- data/middleman-cloudfront.gemspec +1 -0
- data/spec/lib/middleman-cloudfront/commands_spec.rb +58 -0
- data/spec/spec_helper.rb +10 -0
- metadata +34 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ceeae12fb6b9a58a9af56cb8ad6c8c0a01064ba
|
4
|
+
data.tar.gz: 4eccab87e01e2070bf51054b2a59e34f07ac0799
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecaaf4fc80e0d53f7987b75ea905333f7a6b2ea0284f7e15e190851153feb11816e5cec552c16ba67d520f4cb613c6c3cd1ddc6ac78b5f35ba219b2ac1956048
|
7
|
+
data.tar.gz: 939a74033b608adf00b574f7dca2715044d4f140801a195c745be13af4bb17c16193f1c175ece3b6adc2576df5e637c6e4a40e82f9f0f452af4b90846bb7e1d0
|
data/.travis.yml
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
guard 'rspec', cli: '--drb --profile', all_after_pass: false do
|
2
|
+
# Specs
|
3
|
+
watch(%r(^spec/.+_spec\.rb$))
|
4
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
5
|
+
watch(%r(^spec/support/(.+)\.rb$)) { 'spec' }
|
6
|
+
|
7
|
+
# Files
|
8
|
+
watch(%r(^lib/(.+)\.rb$)) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
9
|
+
end
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
Bundler::GemHelper.install_tasks
|
3
5
|
|
@@ -9,8 +11,6 @@ end
|
|
9
11
|
|
10
12
|
require 'rake/clean'
|
11
13
|
|
12
|
-
task :test => ["cucumber"]
|
13
|
-
|
14
14
|
require "middleman-cloudfront/pkg-info"
|
15
15
|
|
16
16
|
PACKAGE = "#{Middleman::CloudFront::PACKAGE}"
|
@@ -32,4 +32,6 @@ task :release => :package do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
RSpec::Core::RakeTask.new(:spec)
|
36
|
+
|
37
|
+
task :default => :spec
|
@@ -33,6 +33,8 @@ module Middleman
|
|
33
33
|
# If there are more than 1000 files to invalidate, do so sequentially and wait until each validation is ready.
|
34
34
|
# If there are max 1000 files, create the invalidation and return immediately.
|
35
35
|
files = list_files(options.filter)
|
36
|
+
return if files.empty?
|
37
|
+
|
36
38
|
if files.count <= INVALIDATION_LIMIT
|
37
39
|
puts "Invalidating #{files.count} files. It might take 10 to 15 minutes until all files are invalidated."
|
38
40
|
puts 'Please check the AWS Management Console to see the status of the invalidation.'
|
@@ -54,18 +56,18 @@ module Middleman
|
|
54
56
|
def options
|
55
57
|
::Middleman::Application.server.inst.cloudfront_options
|
56
58
|
rescue
|
57
|
-
raise Error, <<-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
raise Error, <<-TEXT
|
60
|
+
ERROR: You need to activate the cloudfront extension in config.rb.
|
61
|
+
|
62
|
+
The example configuration is:
|
63
|
+
activate :cloudfront do |cf|
|
64
|
+
cf.access_key_id = 'I'
|
65
|
+
cf.secret_access_key = 'love'
|
66
|
+
cf.distribution_id = 'cats'
|
67
|
+
cf.filter = /\.html/i # default /.*/
|
68
|
+
cf.after_build = true # default is false
|
69
|
+
end
|
70
|
+
TEXT
|
69
71
|
end
|
70
72
|
|
71
73
|
def list_files(filter)
|
@@ -79,9 +81,10 @@ module Middleman
|
|
79
81
|
|
80
82
|
# Add directories of index.html files since they have to be
|
81
83
|
# invalidated as well if :directory_indexes is active
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
files.each do |file|
|
85
|
+
file_dir = file.sub(/\bindex\.html\z/, '')
|
86
|
+
files << file_dir if file_dir != file
|
87
|
+
end
|
85
88
|
|
86
89
|
# Add leading slash
|
87
90
|
files.map! { |f| f.start_with?('/') ? f : "/#{f}" }
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'fog/aws/models/cdn/distributions'
|
4
|
+
|
5
|
+
describe Middleman::Cli::CloudFront do
|
6
|
+
let(:cloudfront) do
|
7
|
+
described_class.new.tap do |cloudfront|
|
8
|
+
cloudfront.stub(:options).and_return Middleman::CloudFront::Options.new(
|
9
|
+
'access_key_id_123',
|
10
|
+
'secret_access_key_123',
|
11
|
+
'distribution_id_123',
|
12
|
+
'filter_123',
|
13
|
+
'after_build_123'
|
14
|
+
);
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:distribution) { double('distribution', invalidations: double('invalidations')) }
|
19
|
+
|
20
|
+
describe '#invalidate' do
|
21
|
+
before do
|
22
|
+
Fog::CDN::AWS::Distributions.any_instance.stub(:get).and_return(distribution)
|
23
|
+
distribution.invalidations.stub(:create) do
|
24
|
+
double('invalidation', status: 'InProgress', wait_for: ->{} )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'gets the correct distribution' do
|
29
|
+
cloudfront.stub(:list_files).and_return []
|
30
|
+
expect_any_instance_of(Fog::CDN::AWS::Distributions).to receive(:get).with('distribution_id_123')
|
31
|
+
cloudfront.invalidate
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the amount of files to invalidate is under the limit' do
|
35
|
+
it 'divides them up in packages and creates one invalidation per package' do
|
36
|
+
files = (1..Middleman::Cli::CloudFront::INVALIDATION_LIMIT).map do |i|
|
37
|
+
"file_#{i}"
|
38
|
+
end
|
39
|
+
cloudfront.stub(:list_files).and_return files
|
40
|
+
expect(distribution.invalidations).to receive(:create).once.with(paths: files)
|
41
|
+
cloudfront.invalidate
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the amount of files to invalidate is over the limit' do
|
46
|
+
it 'creates only one invalidation with all of them' do
|
47
|
+
files = (1..(Middleman::Cli::CloudFront::INVALIDATION_LIMIT * 3)).map do |i|
|
48
|
+
"file_#{i}"
|
49
|
+
end
|
50
|
+
cloudfront.stub(:list_files).and_return files
|
51
|
+
expect(distribution.invalidations).to receive(:create).once.with(paths: files[0, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
|
52
|
+
expect(distribution.invalidations).to receive(:create).once.with(paths: files[Middleman::Cli::CloudFront::INVALIDATION_LIMIT, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
|
53
|
+
expect(distribution.invalidations).to receive(:create).once.with(paths: files[Middleman::Cli::CloudFront::INVALIDATION_LIMIT * 2, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
|
54
|
+
cloudfront.invalidate
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-cloudfront
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andrey Korzhuev
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: middleman-core
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ~>
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -31,7 +28,6 @@ dependencies:
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: fog
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
32
|
- - ~>
|
37
33
|
- !ruby/object:Gem::Version
|
@@ -39,7 +35,6 @@ dependencies:
|
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
39
|
- - ~>
|
45
40
|
- !ruby/object:Gem::Version
|
@@ -47,83 +42,87 @@ dependencies:
|
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rake
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: cucumber
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - '>='
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: '0'
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - '>='
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0'
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: aruba
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - '>='
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: '0'
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - '>='
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: '0'
|
95
84
|
- !ruby/object:Gem::Dependency
|
96
85
|
name: fivemat
|
97
86
|
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
87
|
requirements:
|
100
|
-
- -
|
88
|
+
- - '>='
|
101
89
|
- !ruby/object:Gem::Version
|
102
90
|
version: '0'
|
103
91
|
type: :development
|
104
92
|
prerelease: false
|
105
93
|
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
94
|
requirements:
|
108
|
-
- -
|
95
|
+
- - '>='
|
109
96
|
- !ruby/object:Gem::Version
|
110
97
|
version: '0'
|
111
98
|
- !ruby/object:Gem::Dependency
|
112
99
|
name: simplecov
|
113
100
|
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
101
|
requirements:
|
116
|
-
- -
|
102
|
+
- - '>='
|
117
103
|
- !ruby/object:Gem::Version
|
118
104
|
version: '0'
|
119
105
|
type: :development
|
120
106
|
prerelease: false
|
121
107
|
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
108
|
requirements:
|
124
|
-
- -
|
109
|
+
- - '>='
|
125
110
|
- !ruby/object:Gem::Version
|
126
111
|
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: guard-rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ~>
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 3.0.3
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 3.0.3
|
127
126
|
description: Adds ability to invalidate a specific set of files in your CloudFront
|
128
127
|
cache
|
129
128
|
email:
|
@@ -135,6 +134,7 @@ files:
|
|
135
134
|
- .gitignore
|
136
135
|
- .travis.yml
|
137
136
|
- Gemfile
|
137
|
+
- Guardfile
|
138
138
|
- LICENSE
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
@@ -145,29 +145,30 @@ files:
|
|
145
145
|
- lib/middleman-cloudfront/pkg-info.rb
|
146
146
|
- lib/middleman_extension.rb
|
147
147
|
- middleman-cloudfront.gemspec
|
148
|
+
- spec/lib/middleman-cloudfront/commands_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
148
150
|
homepage: https://github.com/andrusha/middleman-cloudfront
|
149
151
|
licenses: []
|
152
|
+
metadata: {}
|
150
153
|
post_install_message:
|
151
154
|
rdoc_options: []
|
152
155
|
require_paths:
|
153
156
|
- lib
|
154
157
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
158
|
requirements:
|
157
|
-
- -
|
159
|
+
- - '>='
|
158
160
|
- !ruby/object:Gem::Version
|
159
161
|
version: '0'
|
160
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
163
|
requirements:
|
163
|
-
- -
|
164
|
+
- - '>='
|
164
165
|
- !ruby/object:Gem::Version
|
165
166
|
version: '0'
|
166
167
|
requirements: []
|
167
168
|
rubyforge_project: middleman-cloudfront
|
168
|
-
rubygems_version:
|
169
|
+
rubygems_version: 2.0.14
|
169
170
|
signing_key:
|
170
|
-
specification_version:
|
171
|
+
specification_version: 4
|
171
172
|
summary: Invalidate CloudFront cache after deployment to S3
|
172
173
|
test_files:
|
173
174
|
- features/support/env.rb
|