capistrano-s3 0.2.5 → 0.2.6
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 +15 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile.lock +6 -6
- data/NEWS +7 -0
- data/README.md +52 -14
- data/capistrano-s3.gemspec +2 -2
- data/lib/capistrano/s3.rb +11 -7
- data/lib/capistrano/s3/publisher.rb +49 -23
- metadata +7 -15
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTU0Yjg4Y2JlOTIyNmUwYzg0NDRmNWY5MDdkNGU0MjJlMGQxNGJkNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTE5ODIwOTAwZDJiMDQ0YmViNTlmODI0MTIxNjQ2M2YwYWU0MjU4NA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZThlYmNlOGY0Y2FjZGYxZTRlMjcyNGZlZDdlZTFkYzY4ZTZhODIyMjc4NzBj
|
10
|
+
ZDdlNDc3MmVmNTZlZjVmOTBiMDM5MjVmZGRkZTEzZTgyNzIyMTE1Y2MzYTEw
|
11
|
+
NTJkMjk1OTg1OGQ4ZWJiNmNhNTg2ZTk2ZTBiZjI3ZmY0OWRkMzQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2VlNzAxYWQ0N2UzNTdlMDg0MDExNGU2NTU1NTllZDQ1ODZiMzFjMWI4Yzk5
|
14
|
+
MTYwYmU0ZjY5ZWU1OThkNzcyMjM3Mzk5OGZhNTI4ZWMzMmZkODk0MzEyNzlh
|
15
|
+
YWY4YTQxMWQ5OTU3Mzc5NjRkZGQ0ZDY3OGM3YzQwYjhhNDkzNzA=
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
capistrano-s3 (0.2.
|
4
|
+
capistrano-s3 (0.2.6)
|
5
5
|
aws-sdk
|
6
6
|
capistrano
|
7
7
|
mime-types
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
aws-sdk (1.8.
|
12
|
+
aws-sdk (1.8.5)
|
13
13
|
json (~> 1.4)
|
14
14
|
nokogiri (>= 1.4.4)
|
15
15
|
uuidtools (~> 2.1)
|
@@ -19,9 +19,9 @@ GEM
|
|
19
19
|
net-sftp (>= 2.0.0)
|
20
20
|
net-ssh (>= 2.0.14)
|
21
21
|
net-ssh-gateway (>= 1.1.0)
|
22
|
-
highline (1.6.
|
22
|
+
highline (1.6.16)
|
23
23
|
json (1.7.7)
|
24
|
-
mime-types (1.
|
24
|
+
mime-types (1.22)
|
25
25
|
net-scp (1.1.0)
|
26
26
|
net-ssh (>= 2.6.5)
|
27
27
|
net-sftp (2.1.1)
|
@@ -29,8 +29,8 @@ GEM
|
|
29
29
|
net-ssh (2.6.6)
|
30
30
|
net-ssh-gateway (1.2.0)
|
31
31
|
net-ssh (>= 2.6.5)
|
32
|
-
nokogiri (1.5.
|
33
|
-
rake (10.0.
|
32
|
+
nokogiri (1.5.9)
|
33
|
+
rake (10.0.4)
|
34
34
|
uuidtools (2.1.3)
|
35
35
|
|
36
36
|
PLATFORMS
|
data/NEWS
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
New in 0.2.6
|
2
|
+
|
3
|
+
* Feature : Adds ability to specify redirect location for files. (#13) @aledovsky
|
4
|
+
* Feature : Adds S3 endpoint selection option. (#11) @aledovsky
|
5
|
+
* Improvement : Require fileutils to support newer rubies. (#10) @douglasjarquin
|
6
|
+
* Bugfix : Pass a string to the content_type option (#11) @douglasjarquin
|
7
|
+
|
1
8
|
New in 0.2.5
|
2
9
|
|
3
10
|
* Improvement : signed gem.
|
data/README.md
CHANGED
@@ -8,23 +8,30 @@
|
|
8
8
|
|
9
9
|
## Hosting your website with Amazon S3
|
10
10
|
|
11
|
-
S3 provides special
|
12
|
-
The most important difference is that theses buckets serves an index document (ex. index.html) whenever a user specifies the URL for the root of your website, or a subfolder. And you can point your domain name directly to the S3 bucket cname.
|
11
|
+
Amazon S3 provides special websites enabled buckets that allows you to serve web pages from S3.
|
13
12
|
|
14
|
-
To learn how to setup your website bucket, see [Amazon Documentation](http://docs.
|
13
|
+
To learn how to setup your website bucket, see [Amazon Documentation](http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html).
|
15
14
|
|
16
15
|
## Getting started
|
17
16
|
|
18
|
-
|
17
|
+
Create a project `Gemfile` :
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
```ruby
|
20
|
+
source 'https://rubygems.org'
|
21
|
+
gem 'capistrano-s3'
|
22
|
+
```
|
23
|
+
|
24
|
+
### Setup
|
25
|
+
|
26
|
+
Install gem, init capistrano & create a public folder that will be published :
|
27
|
+
|
28
|
+
bundle install
|
29
|
+
bundle exec capify .
|
30
|
+
mkdir public
|
24
31
|
|
25
|
-
###
|
32
|
+
### Credentials
|
26
33
|
|
27
|
-
|
34
|
+
Set your S3 bucket credentials :
|
28
35
|
|
29
36
|
```ruby
|
30
37
|
# config/deploy.rb
|
@@ -35,9 +42,36 @@ set :access_key_id, "CHANGETHIS"
|
|
35
42
|
set :secret_access_key, "CHANGETHIS"
|
36
43
|
```
|
37
44
|
|
45
|
+
_Note_: If you are using S3 in non-default region (e.g. EU), you should provide
|
46
|
+
corresponding
|
47
|
+
[endpoint](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)
|
48
|
+
via configuration option
|
49
|
+
```ruby
|
50
|
+
set :s3_endpoint, 's3-eu-west-1.amazonaws.com'
|
51
|
+
```
|
52
|
+
|
53
|
+
### Deploying
|
54
|
+
|
55
|
+
Add content to you public folder and deploy with :
|
56
|
+
|
57
|
+
cap deploy
|
58
|
+
|
38
59
|
If you want to deploy to multiple buckets, have a look at
|
39
60
|
[Capistrano multistage](https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension)
|
40
|
-
and
|
61
|
+
and configure a bucket per stage configuration.
|
62
|
+
|
63
|
+
#### Redirecting
|
64
|
+
|
65
|
+
Use `:redirect_options` to natively redirect (via HTTP 301 status code)
|
66
|
+
any hosted page. For example:
|
67
|
+
```ruby
|
68
|
+
set :redirect_options, {
|
69
|
+
'index.html' => 'http://example.org',
|
70
|
+
'another.html' => '/test.html',
|
71
|
+
}
|
72
|
+
```
|
73
|
+
Valid redirect destination should either start with `http` or `https` scheme,
|
74
|
+
or begin with leading slash `/`.
|
41
75
|
|
42
76
|
#### S3 write options
|
43
77
|
|
@@ -49,9 +83,9 @@ set :bucket_write_options, {
|
|
49
83
|
}
|
50
84
|
```
|
51
85
|
|
52
|
-
See aws-sdk [
|
86
|
+
See aws-sdk [S3Client.put_object doc](http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/Client.html#put_object-instance_method) for all available options.
|
53
87
|
|
54
|
-
##
|
88
|
+
## Example of usage
|
55
89
|
|
56
90
|
Our Ruby stack for static websites :
|
57
91
|
|
@@ -69,7 +103,9 @@ before 'deploy' do
|
|
69
103
|
end
|
70
104
|
```
|
71
105
|
|
72
|
-
See our boilerplate
|
106
|
+
See our boilerplate
|
107
|
+
[sinatra-static-bp](https://github.com/hooktstudios/sinatra-static-bp)
|
108
|
+
for an example of the complete setup.
|
73
109
|
|
74
110
|
## Contributing
|
75
111
|
|
@@ -80,3 +116,5 @@ See [CONTRIBUTING.md](https://github.com/hooktstudios/capistrano-s3/blob/master/
|
|
80
116
|

|
81
117
|
|
82
118
|
[capistrano-s3](https://rubygems.org/gems/capistrano-s3) is maintained and funded by [hooktstudios](http://github.com/hooktstudios)
|
119
|
+
|
120
|
+
Thanks & credits also to all other [contributors](https://github.com/hooktstudios/capistrano-s3/contributors).
|
data/capistrano-s3.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.authors = ['Jean-Philippe Doyle','Josh Delsman']
|
4
|
+
s.authors = ['Jean-Philippe Doyle','Josh Delsman','Aleksandrs Ļedovskis','Douglas Jarquin']
|
5
5
|
s.email = ['jeanphilippe.doyle@hooktstudios.com']
|
6
6
|
s.description = 'Enables static websites deployment to Amazon S3 website buckets using Capistrano.'
|
7
7
|
s.summary = 'Build and deploy a static website to Amazon S3'
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
13
13
|
s.name = 'capistrano-s3'
|
14
14
|
s.require_paths = ['lib']
|
15
|
-
s.version = '0.2.
|
15
|
+
s.version = '0.2.6'
|
16
16
|
s.cert_chain = ['certs/j15e.pem']
|
17
17
|
s.signing_key = File.expand_path('~/.gem/private_key.pem') if $0 =~ /gem\z/
|
18
18
|
|
data/lib/capistrano/s3.rb
CHANGED
@@ -2,31 +2,35 @@ require 'capistrano'
|
|
2
2
|
require 'capistrano/s3/publisher'
|
3
3
|
|
4
4
|
unless Capistrano::Configuration.respond_to?(:instance)
|
5
|
-
abort "capistrano-s3 requires Capistrano
|
5
|
+
abort "capistrano-s3 requires Capistrano 2.0 or newer"
|
6
6
|
end
|
7
7
|
|
8
8
|
Capistrano::Configuration.instance(true).load do
|
9
9
|
def _cset(name, *args, &block)
|
10
10
|
set(name, *args, &block) if !exists?(name)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
_cset :deployment_path, Dir.pwd.gsub("\n", "") + "/public"
|
14
14
|
_cset :bucket_write_options, :acl => :public_read
|
15
|
-
|
15
|
+
_cset :s3_endpoint, 's3.amazonaws.com'
|
16
|
+
_cset :redirect_options, {}
|
17
|
+
|
16
18
|
# Deployment recipes
|
17
19
|
namespace :deploy do
|
18
|
-
namespace :s3 do
|
20
|
+
namespace :s3 do
|
19
21
|
desc "Empties bucket of all files. Caution when using this command, as it cannot be undone!"
|
20
22
|
task :empty do
|
21
|
-
Publisher.clear!(access_key_id, secret_access_key)
|
23
|
+
Publisher.clear!(s3_endpoint, access_key_id, secret_access_key, bucket)
|
22
24
|
end
|
23
25
|
|
24
26
|
desc "Upload files to the bucket in the current state"
|
25
27
|
task :upload_files do
|
26
|
-
|
28
|
+
extra_options = { :write => bucket_write_options, :redirect => redirect_options }
|
29
|
+
Publisher.publish!(s3_endpoint, access_key_id, secret_access_key,
|
30
|
+
bucket, deployment_path, extra_options)
|
27
31
|
end
|
28
32
|
end
|
29
|
-
|
33
|
+
|
30
34
|
task :update do
|
31
35
|
s3.upload_files
|
32
36
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'aws/s3'
|
2
2
|
require 'mime/types'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module Publisher
|
5
6
|
|
6
7
|
LAST_PUBLISHED_FILE = '.last_published'
|
7
8
|
|
8
|
-
def self.publish!(key, secret, bucket, source, extra_options)
|
9
|
-
s3 = self.
|
9
|
+
def self.publish!(s3_endpoint, key, secret, bucket, source, extra_options)
|
10
|
+
s3 = self.establish_s3_client_connection!(s3_endpoint, key, secret)
|
10
11
|
|
11
12
|
self.files(source).each do |file|
|
12
13
|
if !File.directory?(file)
|
@@ -15,48 +16,45 @@ module Publisher
|
|
15
16
|
path = self.base_file_path(source, file)
|
16
17
|
path.gsub!(/^\//, "") # Remove preceding slash for S3
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
types = MIME::Types.type_for(File.basename(file))
|
21
|
-
if types.empty?
|
22
|
-
options = {
|
23
|
-
:acl => :public_read
|
24
|
-
}
|
25
|
-
else
|
26
|
-
options = {
|
27
|
-
:acl => :public_read,
|
28
|
-
:content_type => types[0]
|
29
|
-
}
|
30
|
-
end
|
31
|
-
options.merge!(extra_options)
|
32
|
-
s3.buckets[bucket].objects[path].write(contents, options)
|
19
|
+
self.put_object(s3, bucket, path, file, extra_options)
|
33
20
|
end
|
34
21
|
end
|
35
22
|
|
36
23
|
FileUtils.touch(LAST_PUBLISHED_FILE)
|
37
24
|
end
|
38
25
|
|
39
|
-
def self.clear!(key, secret, bucket)
|
40
|
-
s3 = self.
|
26
|
+
def self.clear!(s3_endpoint, key, secret, bucket)
|
27
|
+
s3 = self.establish_s3_connection!(s3_endpoint, key, secret)
|
41
28
|
s3.buckets[bucket].clear!
|
29
|
+
|
30
|
+
FileUtils.rm(LAST_PUBLISHED_FILE)
|
42
31
|
end
|
43
32
|
|
44
33
|
private
|
45
34
|
|
46
35
|
# Establishes the connection to Amazon S3
|
47
|
-
def self.establish_connection!(key, secret)
|
36
|
+
def self.establish_connection!(klass, s3_endpoint, key, secret)
|
48
37
|
# Send logging to STDOUT
|
49
38
|
AWS.config(:logger => Logger.new(STDOUT))
|
50
|
-
|
39
|
+
klass.new(
|
40
|
+
:s3_endpoint => s3_endpoint,
|
51
41
|
:access_key_id => key,
|
52
42
|
:secret_access_key => secret
|
53
43
|
)
|
54
44
|
end
|
55
45
|
|
46
|
+
def self.establish_s3_client_connection!(s3_endpoint, key, secret)
|
47
|
+
self.establish_connection!(AWS::S3::Client, s3_endpoint, key, secret)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.establish_s3_connection!(s3_endpoint, key, secret)
|
51
|
+
self.establish_connection!(AWS::S3, s3_endpoint, key, secret)
|
52
|
+
end
|
53
|
+
|
56
54
|
def self.base_file_path(root, file)
|
57
55
|
file.gsub(root, "")
|
58
56
|
end
|
59
|
-
|
57
|
+
|
60
58
|
def self.files(deployment_path)
|
61
59
|
Dir.glob("#{deployment_path}/**/*")
|
62
60
|
end
|
@@ -65,4 +63,32 @@ module Publisher
|
|
65
63
|
return false unless File.exists? LAST_PUBLISHED_FILE
|
66
64
|
File.mtime(file) < File.mtime(LAST_PUBLISHED_FILE)
|
67
65
|
end
|
68
|
-
|
66
|
+
|
67
|
+
def self.put_object(s3, bucket, path, file, extra_options)
|
68
|
+
options = {
|
69
|
+
:bucket_name => bucket,
|
70
|
+
:key => path,
|
71
|
+
:data => open(file),
|
72
|
+
:acl => :public_read,
|
73
|
+
}
|
74
|
+
|
75
|
+
options.merge!( self.build_content_type_hash(file) )
|
76
|
+
options.merge!( self.build_redirect_hash(path, extra_options[:redirect]) )
|
77
|
+
options.merge!(extra_options[:write])
|
78
|
+
|
79
|
+
s3.put_object(options)
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.build_content_type_hash(file)
|
83
|
+
type = MIME::Types.type_for(File.basename(file))
|
84
|
+
return {} unless type
|
85
|
+
|
86
|
+
{ :content_type => type.first.content_type }
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.build_redirect_hash(path, redirect_options)
|
90
|
+
return {} unless redirect_options && redirect_options[path]
|
91
|
+
|
92
|
+
{ :website_redirect_location => redirect_options[path] }
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jean-Philippe Doyle
|
9
8
|
- Josh Delsman
|
9
|
+
- Aleksandrs Ļedovskis
|
10
|
+
- Douglas Jarquin
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain:
|
@@ -38,12 +39,11 @@ cert_chain:
|
|
38
39
|
MjN3ZTRFMUx2ZlJuNWdWNzdEaWo2czlWNEhIek1CdUx3bk5iOFQrNmxPblVX
|
39
40
|
YnRpSWRkRAplOGM4aTdQbHJ6aFZKLzhzWFVKc0NreUU4ZDJNeVJ5amx4TT0K
|
40
41
|
LS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
41
|
-
date: 2013-
|
42
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
42
43
|
dependencies:
|
43
44
|
- !ruby/object:Gem::Dependency
|
44
45
|
name: aws-sdk
|
45
46
|
requirement: !ruby/object:Gem::Requirement
|
46
|
-
none: false
|
47
47
|
requirements:
|
48
48
|
- - ! '>='
|
49
49
|
- !ruby/object:Gem::Version
|
@@ -51,7 +51,6 @@ dependencies:
|
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
54
|
requirements:
|
56
55
|
- - ! '>='
|
57
56
|
- !ruby/object:Gem::Version
|
@@ -59,7 +58,6 @@ dependencies:
|
|
59
58
|
- !ruby/object:Gem::Dependency
|
60
59
|
name: capistrano
|
61
60
|
requirement: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
61
|
requirements:
|
64
62
|
- - ! '>='
|
65
63
|
- !ruby/object:Gem::Version
|
@@ -67,7 +65,6 @@ dependencies:
|
|
67
65
|
type: :runtime
|
68
66
|
prerelease: false
|
69
67
|
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
68
|
requirements:
|
72
69
|
- - ! '>='
|
73
70
|
- !ruby/object:Gem::Version
|
@@ -75,7 +72,6 @@ dependencies:
|
|
75
72
|
- !ruby/object:Gem::Dependency
|
76
73
|
name: mime-types
|
77
74
|
requirement: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
75
|
requirements:
|
80
76
|
- - ! '>='
|
81
77
|
- !ruby/object:Gem::Version
|
@@ -83,7 +79,6 @@ dependencies:
|
|
83
79
|
type: :runtime
|
84
80
|
prerelease: false
|
85
81
|
version_requirements: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
82
|
requirements:
|
88
83
|
- - ! '>='
|
89
84
|
- !ruby/object:Gem::Version
|
@@ -91,7 +86,6 @@ dependencies:
|
|
91
86
|
- !ruby/object:Gem::Dependency
|
92
87
|
name: rake
|
93
88
|
requirement: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
89
|
requirements:
|
96
90
|
- - ! '>='
|
97
91
|
- !ruby/object:Gem::Version
|
@@ -99,7 +93,6 @@ dependencies:
|
|
99
93
|
type: :development
|
100
94
|
prerelease: false
|
101
95
|
version_requirements: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
96
|
requirements:
|
104
97
|
- - ! '>='
|
105
98
|
- !ruby/object:Gem::Version
|
@@ -127,26 +120,25 @@ files:
|
|
127
120
|
homepage: http://github.com/hooktstudios/capistrano-s3
|
128
121
|
licenses:
|
129
122
|
- MIT
|
123
|
+
metadata: {}
|
130
124
|
post_install_message:
|
131
125
|
rdoc_options: []
|
132
126
|
require_paths:
|
133
127
|
- lib
|
134
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
129
|
requirements:
|
137
130
|
- - ! '>='
|
138
131
|
- !ruby/object:Gem::Version
|
139
132
|
version: '0'
|
140
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
134
|
requirements:
|
143
135
|
- - ! '>='
|
144
136
|
- !ruby/object:Gem::Version
|
145
137
|
version: '0'
|
146
138
|
requirements: []
|
147
139
|
rubyforge_project:
|
148
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.3
|
149
141
|
signing_key:
|
150
|
-
specification_version:
|
142
|
+
specification_version: 4
|
151
143
|
summary: Build and deploy a static website to Amazon S3
|
152
144
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|