foresth-cloudfront_asset_host 1.0.6 → 1.0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/cloudfront_asset_host.gemspec +1 -1
- data/lib/cloudfront_asset_host/uploader.rb +24 -16
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.6
|
1
|
+
1.0.6.1
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{foresth-cloudfront_asset_host}
|
8
|
-
s.version = "1.0.6"
|
8
|
+
s.version = "1.0.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Menno van der Sman"]
|
@@ -11,27 +11,31 @@ module CloudfrontAssetHost
|
|
11
11
|
def upload!(options = {})
|
12
12
|
dryrun = options.delete(:dryrun) || false
|
13
13
|
verbose = options.delete(:verbose) || false
|
14
|
+
silent = options.delete(:silent) || false
|
15
|
+
verbose = false if silent
|
14
16
|
|
15
17
|
self.new_keys = []
|
16
18
|
|
17
|
-
puts "-- Updating uncompressed files"
|
18
|
-
upload_keys_with_paths(keys_with_paths, dryrun, verbose, false)
|
19
|
+
puts "-- Updating uncompressed files" unless silent
|
20
|
+
upload_keys_with_paths(keys_with_paths, dryrun, verbose, silent, false)
|
19
21
|
|
20
22
|
if CloudfrontAssetHost.gzip
|
21
|
-
puts "-- Updating compressed files"
|
22
|
-
upload_keys_with_paths(gzip_keys_with_paths, dryrun, verbose, true)
|
23
|
+
puts "-- Updating compressed files" unless silent
|
24
|
+
upload_keys_with_paths(gzip_keys_with_paths, dryrun, verbose, silent, true)
|
23
25
|
end
|
24
26
|
|
25
|
-
delete_old_keys(dryrun, verbose)
|
27
|
+
delete_old_keys(dryrun, verbose, silent)
|
26
28
|
|
27
29
|
@existing_keys = nil
|
28
30
|
end
|
29
31
|
|
30
|
-
def upload_keys_with_paths(keys_paths, dryrun, verbose, gzip)
|
32
|
+
def upload_keys_with_paths(keys_paths, dryrun, verbose, silent, gzip)
|
33
|
+
counter = 0
|
31
34
|
keys_paths.each do |key, path|
|
32
35
|
new_keys << key
|
33
36
|
if !existing_keys.include?(key) || CloudfrontAssetHost.css?(path) && rewrite_all_css?
|
34
37
|
puts "+ #{key}" if verbose
|
38
|
+
counter += 1
|
35
39
|
|
36
40
|
extension = File.extname(path)[1..-1]
|
37
41
|
|
@@ -45,6 +49,20 @@ module CloudfrontAssetHost
|
|
45
49
|
puts "= #{key}" if verbose
|
46
50
|
end
|
47
51
|
end
|
52
|
+
puts "#{counter} key(s) updated" unless silent || verbose
|
53
|
+
end
|
54
|
+
|
55
|
+
def delete_old_keys(dryrun, verbose, silent)
|
56
|
+
puts "-- Removing old files" unless silent
|
57
|
+
counter = 0
|
58
|
+
(existing_keys - new_keys).uniq.each do |key|
|
59
|
+
unless new_keys.include?(key)
|
60
|
+
puts "- #{key}" if verbose
|
61
|
+
counter += 1
|
62
|
+
bucket.delete_folder(key) unless dryrun
|
63
|
+
end
|
64
|
+
end
|
65
|
+
puts "#{counter} key(s) removed" unless silent || verbose
|
48
66
|
end
|
49
67
|
|
50
68
|
def gzipped_path(path)
|
@@ -85,16 +103,6 @@ module CloudfrontAssetHost
|
|
85
103
|
end
|
86
104
|
end
|
87
105
|
|
88
|
-
def delete_old_keys(dryrun, verbose)
|
89
|
-
puts "-- Removing expired files" if verbose
|
90
|
-
(existing_keys - new_keys).uniq.each do |key|
|
91
|
-
unless new_keys.include?(key)
|
92
|
-
puts "- #{key}" if verbose
|
93
|
-
bucket.delete_folder(key) unless dryrun
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
106
|
def rewrite_all_css?
|
99
107
|
@rewrite_all_css ||= !keys_with_paths.delete_if { |key, path| existing_keys.include?(key) || !CloudfrontAssetHost.image?(path) }.empty?
|
100
108
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foresth-cloudfront_asset_host
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 69
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 6
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 1.0.6.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Menno van der Sman
|