aws-s3-deploy 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/aws-s3-deploy.gemspec +1 -0
- data/bin/deploy +4 -2
- data/lib/deploy.rb +51 -9
- data/lib/deploy/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e07bc8ffc204fcfb661585fa8226194ae9db74a4
|
4
|
+
data.tar.gz: ccee4626042dc56fbc73be6e9e6fde6d1c8db2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe578e93388df318b87076730f73bfdd41f5c759cd5657b24abf06b56f08f6eecc601a4fefe8e20975fb0914225fc22ca37d885d20fc3462ed0f1de7340eff63
|
7
|
+
data.tar.gz: 6f2c3c576b3c3758157b51d1fbc6076b266b976c8744d3b1f92607764044bd6aa433a68f99896f89391fdeb9ee90ea8480ba061b9d3ea1e01dd2b1ec8c561617
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/aws-s3-deploy.gemspec
CHANGED
data/bin/deploy
CHANGED
@@ -8,10 +8,12 @@ if File.exist?( '.deploy')
|
|
8
8
|
else
|
9
9
|
config = {}
|
10
10
|
puts "No Config file for this folder found... let's create one"
|
11
|
-
|
11
|
+
|
12
|
+
# We need to accept empty string, as wel for KEY and SECRET
|
13
|
+
puts "Your Amazon AWS Key(Leave Empty to use AWS_KEY enviornment variable):"
|
12
14
|
config['aws_key'] = gets.strip
|
13
15
|
|
14
|
-
puts "Your Amazon AWS Secret:"
|
16
|
+
puts "Your Amazon AWS Secret (Leave Empty to use AWS_SECRET enviornment variable):"
|
15
17
|
config['aws_secret'] = gets.strip
|
16
18
|
|
17
19
|
puts "The Bucket you'd like to deploy to:"
|
data/lib/deploy.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "deploy/version"
|
2
|
+
require 'closure-compiler'
|
2
3
|
require 'aws-sdk'
|
3
4
|
require 'yaml'
|
4
5
|
|
@@ -6,7 +7,10 @@ require 'yaml'
|
|
6
7
|
module Deploy
|
7
8
|
|
8
9
|
def self.load_config
|
9
|
-
|
10
|
+
|
11
|
+
# We need to account for AWS Keys stored in
|
12
|
+
# ENV Variables here.
|
13
|
+
defaults = {'aws_region' => 'us-west-2', 'compress' => true}
|
10
14
|
@config = YAML.load_file("#{Dir.pwd}/.deploy")
|
11
15
|
@config = defaults.merge(@config)
|
12
16
|
end
|
@@ -16,8 +20,11 @@ module Deploy
|
|
16
20
|
'aws_key' => nil,
|
17
21
|
'aws_secret' => nil,
|
18
22
|
'aws_bucket' => nil,
|
19
|
-
'deploy_folder' => nil
|
23
|
+
'deploy_folder' => nil,
|
24
|
+
'compress' => true
|
20
25
|
}.merge(config)
|
26
|
+
config['aws_key'] = ENV['AWS_KEY'] if config['aws_key'].empty?
|
27
|
+
config['aws_secret'] = ENV['AWS_SECRET'] if config['aws_secret'].empty?
|
21
28
|
File.open("#{Dir.pwd}/.deploy", 'w+') { |file| file.write(config.to_yaml) }
|
22
29
|
end
|
23
30
|
|
@@ -33,26 +40,61 @@ module Deploy
|
|
33
40
|
|
34
41
|
if File.file?(file)
|
35
42
|
remote_file = file.sub("#{@config['deploy_folder']}/", "")
|
36
|
-
|
43
|
+
|
37
44
|
remote = bucket.objects[remote_file]
|
38
45
|
|
39
46
|
content_type = case file.split('.').last
|
40
47
|
when 'css'
|
48
|
+
Deploy::Compress.compress(file)
|
41
49
|
'text/css'
|
42
50
|
when 'js'
|
43
|
-
|
51
|
+
Deploy::Compress.compile(file)
|
52
|
+
'application/javascript'
|
44
53
|
when 'otf'
|
45
54
|
'font/opentype'
|
46
55
|
when 'svg'
|
47
56
|
'image/svg+xml'
|
57
|
+
when 'xml'
|
58
|
+
'text/xml'
|
59
|
+
when 'html', 'htm'
|
60
|
+
'text/html'
|
61
|
+
when 'gz'
|
62
|
+
'skip'
|
48
63
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
64
|
+
|
65
|
+
unless content_type == 'skip'
|
66
|
+
if File.exist?("#{file}.gz")
|
67
|
+
puts "+ #{file} (compressed)"
|
68
|
+
remote.write(file: "#{file}.gz", content_encoding: 'gzip', content_type: content_type)
|
69
|
+
else
|
70
|
+
puts "+ #{file}"
|
71
|
+
remote.write(file: file, content_type: content_type)
|
72
|
+
end
|
73
|
+
remote.acl = :public_read
|
53
74
|
end
|
54
|
-
remote.acl = :public_read
|
55
75
|
end
|
56
76
|
end
|
57
77
|
end
|
58
78
|
end
|
79
|
+
|
80
|
+
|
81
|
+
module Deploy::Compress
|
82
|
+
def self.compress(file)
|
83
|
+
content = File.read(file).encode!('UTF-8', 'UTF-8', :invalid => :replace)
|
84
|
+
gzip(content, file)
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.compile(file)
|
88
|
+
content = File.read(file).encode!('UTF-8', 'UTF-8', :invalid => :replace)
|
89
|
+
content = closure(content, file)
|
90
|
+
gzip(content, file)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.gzip(content, file)
|
94
|
+
Zlib::GzipWriter.open("#{file}.gz") {|f| f.write(content) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.closure(content, file)
|
98
|
+
Closure::Compiler.new.compile(content)
|
99
|
+
end
|
100
|
+
end
|
data/lib/deploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-s3-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Centinaro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.26.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: closure-compiler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.10
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.1.10
|
55
69
|
description: Deploy static files to AWS S3.
|
56
70
|
email:
|
57
71
|
- bill@theresnobox.net
|
@@ -61,6 +75,7 @@ extensions: []
|
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
63
77
|
- .gitignore
|
78
|
+
- .ruby-version
|
64
79
|
- Gemfile
|
65
80
|
- LICENSE.txt
|
66
81
|
- README.md
|
@@ -94,3 +109,4 @@ signing_key:
|
|
94
109
|
specification_version: 4
|
95
110
|
summary: Deploys static assets to AWS S3.
|
96
111
|
test_files: []
|
112
|
+
has_rdoc:
|