capistrano-s3 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +4 -0
- data/README.md +8 -0
- data/lib/capistrano/s3/defaults.rb +2 -1
- data/lib/capistrano/s3/publisher.rb +4 -4
- data/lib/capistrano/s3/version.rb +1 -1
- data/lib/capistrano/tasks/capistrano_2.rb +1 -1
- data/lib/capistrano/tasks/capistrano_3.rb +1 -1
- data/spec/publisher_spec.rb +48 -3
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb5552bb93390a37dfef42b1c2f04ab86f8c24b2
|
4
|
+
data.tar.gz: 7e90088960110cc77b870709ab8e1b7cc1d00af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96b33af80859e1be1a7df56b268d6f8f6bf6a9061c16fd006ff4d2d702571bbfaa36803a7bc228db9385d088ac6cacc3b6a3e5dcbd35400467f00da5ac88ec05
|
7
|
+
data.tar.gz: aaeec8a903a3e4e1c1d44246108217e33b6a80046df824ed12a86b71e90c4ddb84941166b9c1465f37eed448e5c0ad85d6c87e7b9a7e85e18ef95db26884388f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -139,6 +139,14 @@ set :distribution_id, "CHANGETHIS"
|
|
139
139
|
set :invalidations, [ "/index.html", "/assets/*" ]
|
140
140
|
```
|
141
141
|
|
142
|
+
### Exclude files and directories
|
143
|
+
|
144
|
+
You can set a list of files or directories to exclude from upload. The path must relative to `deployment_path` and use the `dir/**/*` pattern to exclude directories.
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
set :exclusions, [ "index.html", "resources/**/*" ]
|
148
|
+
```
|
149
|
+
|
142
150
|
## Example of usage
|
143
151
|
|
144
152
|
Our Ruby stack for static websites:
|
@@ -7,11 +7,11 @@ module Capistrano
|
|
7
7
|
module Publisher
|
8
8
|
LAST_PUBLISHED_FILE = '.last_published'
|
9
9
|
|
10
|
-
def self.publish!(s3_endpoint, key, secret, bucket, source, distribution_id, invalidations, only_gzip, extra_options)
|
10
|
+
def self.publish!(s3_endpoint, key, secret, bucket, source, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
11
11
|
s3 = self.establish_s3_client_connection!(s3_endpoint, key, secret)
|
12
12
|
updated = false
|
13
13
|
|
14
|
-
self.files(source).each do |file|
|
14
|
+
self.files(source, exclusions).each do |file|
|
15
15
|
if !File.directory?(file)
|
16
16
|
next if self.published?(file)
|
17
17
|
next if only_gzip && self.has_gzipped_version?(file)
|
@@ -78,8 +78,8 @@ module Capistrano
|
|
78
78
|
file.gsub(root, "")
|
79
79
|
end
|
80
80
|
|
81
|
-
def self.files(deployment_path)
|
82
|
-
Dir.glob("#{deployment_path}/**/*")
|
81
|
+
def self.files(deployment_path, exclusions)
|
82
|
+
Dir.glob("#{deployment_path}/**/*") - Dir.glob(exclusions.map{ |e| "#{deployment_path}/#{e}" })
|
83
83
|
end
|
84
84
|
|
85
85
|
def self.published?(file)
|
@@ -18,7 +18,7 @@ module Capistrano
|
|
18
18
|
task :upload_files do
|
19
19
|
extra_options = { :write => bucket_write_options, :redirect => redirect_options }
|
20
20
|
S3::Publisher.publish!(s3_endpoint, access_key_id, secret_access_key,
|
21
|
-
bucket, deployment_path, distribution_id, invalidations, only_gzip, extra_options)
|
21
|
+
bucket, deployment_path, distribution_id, invalidations, exclusions, only_gzip, extra_options)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -15,7 +15,7 @@ namespace :deploy do
|
|
15
15
|
task :upload_files do
|
16
16
|
extra_options = { :write => fetch(:bucket_write_options), :redirect => fetch(:redirect_options) }
|
17
17
|
Capistrano::S3::Publisher.publish!(fetch(:s3_endpoint), fetch(:access_key_id), fetch(:secret_access_key),
|
18
|
-
fetch(:bucket), fetch(:deployment_path), fetch(:distribution_id), fetch(:invalidations), fetch(:only_gzip), extra_options)
|
18
|
+
fetch(:bucket), fetch(:deployment_path), fetch(:distribution_id), fetch(:invalidations), fetch(:exclusions), fetch(:only_gzip), extra_options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/publisher_spec.rb
CHANGED
@@ -10,17 +10,62 @@ describe Capistrano::S3::Publisher do
|
|
10
10
|
context "on publish!" do
|
11
11
|
it "publish all files" do
|
12
12
|
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(8)
|
13
|
-
AWS::CloudFront::Client::V20141106.any_instance.expects(:create_invalidation).once
|
14
13
|
|
15
14
|
path = File.join(@root, 'sample')
|
16
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [
|
15
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], [], false, {})
|
17
16
|
end
|
18
17
|
|
19
18
|
it "publish only gzip files when option is enabled" do
|
20
19
|
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(4)
|
21
20
|
|
22
21
|
path = File.join(@root, 'sample')
|
23
|
-
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], true, {})
|
22
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], [], true, {})
|
24
23
|
end
|
24
|
+
|
25
|
+
context "invalidations" do
|
26
|
+
it "publish all files with invalidations" do
|
27
|
+
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(8)
|
28
|
+
AWS::CloudFront::Client::V20141106.any_instance.expects(:create_invalidation).once
|
29
|
+
|
30
|
+
path = File.join(@root, 'sample')
|
31
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', ['*'], [], false, {})
|
32
|
+
end
|
33
|
+
|
34
|
+
it "publish all files without invalidations" do
|
35
|
+
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(8)
|
36
|
+
AWS::CloudFront::Client::V20141106.any_instance.expects(:create_invalidation).never
|
37
|
+
|
38
|
+
path = File.join(@root, 'sample')
|
39
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], [], false, {})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "exclusions" do
|
44
|
+
it "exclude one files" do
|
45
|
+
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(7)
|
46
|
+
|
47
|
+
path = File.join(@root, 'sample')
|
48
|
+
exclude_paths = ['fonts/cantarell-regular-webfont.svg']
|
49
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], exclude_paths, false, {})
|
50
|
+
end
|
51
|
+
|
52
|
+
it "exclude multiple files" do
|
53
|
+
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(6)
|
54
|
+
|
55
|
+
path = File.join(@root, 'sample')
|
56
|
+
exclude_paths = ['fonts/cantarell-regular-webfont.svg', 'fonts/cantarell-regular-webfont.svg.gz']
|
57
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], exclude_paths, false, {})
|
58
|
+
end
|
59
|
+
|
60
|
+
it "exclude directory" do
|
61
|
+
AWS::S3::Client::V20060301.any_instance.expects(:put_object).times(0)
|
62
|
+
|
63
|
+
path = File.join(@root, 'sample')
|
64
|
+
exclude_paths = ['fonts/**/*']
|
65
|
+
Capistrano::S3::Publisher.publish!('s3.amazonaws.com', 'abc', '123', 'mybucket.amazonaws.com', path, 'cf123', [], exclude_paths, false, {})
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
25
70
|
end
|
26
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Doyle
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
t/JsZnAlWYkJIees2SFV5X/t34oeMu04yY2u9y2YBqKovR97m5YF7zqgx0JODV0x
|
37
37
|
ytwUJvEjznBnJV4OoDE=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2017-01-
|
39
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aws-sdk
|
metadata.gz.sig
CHANGED
Binary file
|