asset_hash 0.2.0 → 0.2.1
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.
- data/lib/tasks/asset_hash.rake +27 -2
- metadata +2 -2
data/lib/tasks/asset_hash.rake
CHANGED
|
@@ -21,6 +21,19 @@ namespace :asset do
|
|
|
21
21
|
secret_access_key = STDIN.gets.strip
|
|
22
22
|
STDOUT.puts "Enter the url of the domain to distribute on cloudfront (eg. google.com)"
|
|
23
23
|
cloudfront_distribution_url = STDIN.gets.strip
|
|
24
|
+
origin_protocol = nil
|
|
25
|
+
while origin_protocol == nil do
|
|
26
|
+
STDOUT.puts "What type of Origin Protocol Policy would you like for your distribution"
|
|
27
|
+
STDOUT.puts "(type one of 'match-viewer' or 'http-only', or leave blank for match-viewer)"
|
|
28
|
+
input = STDIN.gets.strip.downcase
|
|
29
|
+
if input == 'match-viewer' || input == 'http-only'
|
|
30
|
+
origin_protocol = input
|
|
31
|
+
elsif input == ""
|
|
32
|
+
origin_protocol = 'match-viewer'
|
|
33
|
+
else
|
|
34
|
+
STDOUT.puts "Invalid input received: #{input.inspect}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
24
37
|
STDOUT.puts "Enter a description for your cloudfront distribution"
|
|
25
38
|
cloudfront_distribution_description = STDIN.gets.strip
|
|
26
39
|
AWS::S3::Base.establish_connection!(
|
|
@@ -40,7 +53,7 @@ namespace :asset do
|
|
|
40
53
|
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
|
|
41
54
|
<CustomOrigin>
|
|
42
55
|
<DNSName>#{cloudfront_distribution_url}</DNSName>
|
|
43
|
-
<OriginProtocolPolicy
|
|
56
|
+
<OriginProtocolPolicy>#{origin_protocol}</OriginProtocolPolicy>
|
|
44
57
|
</CustomOrigin>
|
|
45
58
|
<Comment>#{cloudfront_distribution_description}</Comment>
|
|
46
59
|
<Enabled>true</Enabled>
|
|
@@ -51,7 +64,19 @@ EOF
|
|
|
51
64
|
http.use_ssl = true
|
|
52
65
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
53
66
|
res = http.request(req)
|
|
54
|
-
|
|
67
|
+
if res.code == '201'
|
|
68
|
+
distribution_id = res.body.match(/\<Id\>(.+)\<\/Id\>/)[1]
|
|
69
|
+
distribution_domain = res.body.match(/\<DomainName>(.+)<\/DomainName>/)[1]
|
|
70
|
+
STDOUT.puts "Distribution created: #{distribution_id} with domain #{distribution_domain}"
|
|
71
|
+
STDOUT.puts ""
|
|
72
|
+
STDOUT.puts "Please paste the following in your config/production.rb:"
|
|
73
|
+
STDOUT.puts ""
|
|
74
|
+
STDOUT.puts "config.action_controller.asset_host = Proc.new do |source, request|"
|
|
75
|
+
STDOUT.puts " request.ssl? ? 'https://#{distribution_domain}' : 'http://#{distribution_domain}'"
|
|
76
|
+
STDOUT.puts "end"
|
|
77
|
+
else
|
|
78
|
+
STDOUT.puts "Distribution failed: #{res.body}"
|
|
79
|
+
end
|
|
55
80
|
rescue LoadError => e
|
|
56
81
|
STDERR.puts "Could not find the aws-s3 gem, Run `gem install aws-s3` to install s3"
|
|
57
82
|
end
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: asset_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.2.
|
|
5
|
+
version: 0.2.1
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Donald Piret
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-05-27 00:00:00 +08:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|