aws-s3-deploy 0.0.2 → 0.1.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: bb0958ebf6cad60b0ba102a5de763182c0e44f59
4
- data.tar.gz: 8329447265d80c86c7e61e326c46a53fa50f3cc6
3
+ metadata.gz: e07bc8ffc204fcfb661585fa8226194ae9db74a4
4
+ data.tar.gz: ccee4626042dc56fbc73be6e9e6fde6d1c8db2dc
5
5
  SHA512:
6
- metadata.gz: 5540891c568af1bfb10bbb5cb0eb9230fccb1139c7c87603381118b95c9177c3dbbe8072388acd0ec6114372942dab001a83d0a2869955a1f1c032c839bdc4b8
7
- data.tar.gz: 4d9104656411af88f389202685c689e723d21191cffe0ae941852833329fa8bd0065ab5488c753a76db97c368a2282680e4f49022374c89074d6032b89d7ca94
6
+ metadata.gz: fe578e93388df318b87076730f73bfdd41f5c759cd5657b24abf06b56f08f6eecc601a4fefe8e20975fb0914225fc22ca37d885d20fc3462ed0f1de7340eff63
7
+ data.tar.gz: 6f2c3c576b3c3758157b51d1fbc6076b266b976c8744d3b1f92607764044bd6aa433a68f99896f89391fdeb9ee90ea8480ba061b9d3ea1e01dd2b1ec8c561617
@@ -0,0 +1 @@
1
+ 2.0.0
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_dependency "aws-sdk", "~> 1.26.0"
24
+ spec.add_dependency "closure-compiler", "1.1.10"
24
25
  end
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
- puts "Your Amazon AWS Key:"
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:"
@@ -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
- defaults = {'aws_region' => 'us-west-2'}
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
- puts "+ #{file}"
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
- 'application/javascript'
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
- if File.exist?("#{file}.gz")
50
- remote.write(file: "#{file}.gz", content_encoding: 'gzip', content_type: content_type)
51
- else
52
- remote.write(file: file, content_type: content_type)
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
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module S3
3
3
  module Deploy
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
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.2
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: 2013-11-15 00:00:00.000000000 Z
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: