capistrano-s3 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7181c1cd58ffcacd370bc1801a4a1de156b60490
4
- data.tar.gz: 48c6ab3151aa29bc96df90bcbb50bbb66340f2f7
3
+ metadata.gz: cb5552bb93390a37dfef42b1c2f04ab86f8c24b2
4
+ data.tar.gz: 7e90088960110cc77b870709ab8e1b7cc1d00af0
5
5
  SHA512:
6
- metadata.gz: df7c91285663a990bef6c758a9119b11fde17c6fc6e82b01b753c62925331f68f757d8132338aae56787d87e22b3377c8a566d4e5db2550228eeaab87986a21f
7
- data.tar.gz: eb45abf3f729d1f3c92245c2e76bc505651ffd5eb94dc4ab2c6bb591a12511570cb870c9f97a78feb8918a862d40dd55bb507f4ce8fb38eb79a1cf4f12b48b71
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
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.2.0
4
+
5
+ Feature : Add exclusions (#30) @exoszajzbuk
6
+
3
7
  ## v1.1.0
4
8
 
5
9
  Feature : Add support for Cloudfront invalidations (#29) @exoszajzbuk
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,7 +7,8 @@ module Capistrano
7
7
  :s3_endpoint => "s3.amazonaws.com",
8
8
  :redirect_options => {},
9
9
  :only_gzip => false,
10
- :invalidations => []
10
+ :invalidations => [],
11
+ :exclusions => []
11
12
  }
12
13
 
13
14
  def self.populate(context, set_method)
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module S3
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -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
 
@@ -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', ['*'], false, {})
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.1.0
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-24 00:00:00.000000000 Z
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