s3_website 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/changelog.md +4 -0
- data/lib/cloudfront/invalidator.rb +15 -7
- data/resources/configuration_file_template.yml +2 -0
- data/s3_website.gemspec +1 -1
- data/spec/lib/cloudfront/invalidator_spec.rb +54 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bad4fc74f724a4017ad910badbaeaebd90d0f2b7
|
4
|
+
data.tar.gz: 6c7e6efac417531ef5afec5b94a6bd74e795cc20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47b2d9003a269827e1e0b3f8ebe7bb6816f284209e510009c306c30cf9c426477ca1345af15147cb8ba699b74c23af00f2cb55780586b656909aeb0a969e12e9
|
7
|
+
data.tar.gz: 9bbc213d27d7f8069e85031941252a2604ff28e2c2ac3656c402e43743b29991b7e990f7bac0f4c043883744957605e560eb53f9088ee94706e48aa72af19524
|
data/README.md
CHANGED
@@ -210,6 +210,25 @@ cloudfront_distribution_config:
|
|
210
210
|
Once you've saved the configuration into `s3_website.yml`, you can apply them by
|
211
211
|
running `s3_website cfg apply`.
|
212
212
|
|
213
|
+
#### Invalidating root resources instead of index.htmls
|
214
|
+
|
215
|
+
By default, `s3_website push` calls the CloudFront invalidation API with the
|
216
|
+
file-name-as-it-is. This means that if your file is *article/index.html*, the
|
217
|
+
push command will call the invalidation API on the resource
|
218
|
+
*article/index.html*.
|
219
|
+
|
220
|
+
You can instruct the push command to invalidate the root resource instead of the
|
221
|
+
*index.html* resource by adding the following setting into the configuration
|
222
|
+
file:
|
223
|
+
|
224
|
+
cloudfront_invalidate_root: true
|
225
|
+
|
226
|
+
To recap, this setting instructs s3_website to invalidate the root resource
|
227
|
+
(e.g., *article/*) instead of the filename'd resource (e.g.,
|
228
|
+
*article/index.html).
|
229
|
+
|
230
|
+
No more index.htmls in your URLs!
|
231
|
+
|
213
232
|
### The headless mode
|
214
233
|
|
215
234
|
s3_website has a headless mode, where human interactions are disabled.
|
data/changelog.md
CHANGED
@@ -4,19 +4,27 @@ module S3Website
|
|
4
4
|
def self.invalidate(config, changed_files)
|
5
5
|
aws_key = config['s3_id']
|
6
6
|
aws_secret = config['s3_secret']
|
7
|
-
s3_bucket_name = config['s3_bucket']
|
8
7
|
cloudfront_distribution_id = config['cloudfront_distribution_id']
|
9
|
-
|
10
|
-
:access_key_id => aws_key,
|
11
|
-
:secret_access_key => aws_secret)
|
12
|
-
s3_object_keys = changed_files
|
8
|
+
s3_object_keys = apply_config config, changed_files
|
13
9
|
s3_object_keys << ""
|
14
10
|
report = SimpleCloudfrontInvalidator::CloudfrontClient.new(
|
15
|
-
aws_key, aws_secret, cloudfront_distribution_id
|
16
|
-
|
11
|
+
aws_key, aws_secret, cloudfront_distribution_id
|
12
|
+
).invalidate(s3_object_keys)
|
17
13
|
puts report[:text_report]
|
18
14
|
report[:invalidated_items_count]
|
19
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.apply_config(config, changed_files)
|
20
|
+
if config['cloudfront_invalidate_root']
|
21
|
+
changed_files.map { |changed_file|
|
22
|
+
changed_file.sub /\/index.html$/, '/'
|
23
|
+
}
|
24
|
+
else
|
25
|
+
changed_files
|
26
|
+
end
|
27
|
+
end
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
data/s3_website.gemspec
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe S3Website::Cloudfront::Invalidator do
|
4
|
+
describe 'default behaviour' do
|
5
|
+
let(:config) {
|
6
|
+
{
|
7
|
+
's3_id' => 'aws id',
|
8
|
+
's3_secret' => 'aws secret',
|
9
|
+
'cloudfront_distribution_id' => 'EFXX'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
it 'invalidates the root resource' do
|
14
|
+
invalidator = double('invalidator')
|
15
|
+
SimpleCloudfrontInvalidator::CloudfrontClient.
|
16
|
+
should_receive(:new).
|
17
|
+
with('aws id', 'aws secret', 'EFXX').
|
18
|
+
and_return(invalidator)
|
19
|
+
|
20
|
+
invalidator.
|
21
|
+
should_receive(:invalidate).
|
22
|
+
with(['index.html', '']).
|
23
|
+
and_return(:text_report => 'report txt')
|
24
|
+
|
25
|
+
S3Website::Cloudfront::Invalidator.invalidate(config, ['index.html'])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'option cloudfront_invalidate_root = true' do
|
30
|
+
let(:config) {
|
31
|
+
{
|
32
|
+
's3_id' => 'aws id',
|
33
|
+
's3_secret' => 'aws secret',
|
34
|
+
'cloudfront_distribution_id' => 'EFXX',
|
35
|
+
'cloudfront_invalidate_root' => true
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
it 'invalidates all root resources' do
|
40
|
+
invalidator = double('invalidator')
|
41
|
+
SimpleCloudfrontInvalidator::CloudfrontClient.
|
42
|
+
should_receive(:new).
|
43
|
+
with('aws id', 'aws secret', 'EFXX').
|
44
|
+
and_return(invalidator)
|
45
|
+
|
46
|
+
invalidator.
|
47
|
+
should_receive(:invalidate).
|
48
|
+
with(['article/', '']).
|
49
|
+
and_return(:text_report => 'report txt')
|
50
|
+
|
51
|
+
S3Website::Cloudfront::Invalidator.invalidate(config, ['article/index.html'])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- lib/s3_website/uploader.rb
|
315
315
|
- resources/configuration_file_template.yml
|
316
316
|
- s3_website.gemspec
|
317
|
+
- spec/lib/cloudfront/invalidator_spec.rb
|
317
318
|
- spec/lib/config_loader_spec.rb
|
318
319
|
- spec/lib/endpoint_spec.rb
|
319
320
|
- spec/lib/keyboard_spec.rb
|
@@ -429,6 +430,7 @@ test_files:
|
|
429
430
|
- features/support/test_site_dirs/unpublish-a-post.com/s3_website.yml
|
430
431
|
- features/support/vcr.rb
|
431
432
|
- features/website-performance.feature
|
433
|
+
- spec/lib/cloudfront/invalidator_spec.rb
|
432
434
|
- spec/lib/config_loader_spec.rb
|
433
435
|
- spec/lib/endpoint_spec.rb
|
434
436
|
- spec/lib/keyboard_spec.rb
|