asset_sync 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/asset_sync/asset_sync.rb +5 -3
- data/lib/asset_sync/engine.rb +5 -5
- data/lib/asset_sync/storage.rb +18 -13
- data/lib/asset_sync/version.rb +1 -1
- metadata +11 -11
@@ -22,17 +22,19 @@ module AssetSync
|
|
22
22
|
|
23
23
|
def sync
|
24
24
|
if config.fail_silently?
|
25
|
-
self.
|
25
|
+
self.warn config.errors.full_messages.join(', ') unless config && config.valid?
|
26
26
|
else
|
27
27
|
raise Config::Invalid.new(config.errors.full_messages.join(', ')) unless config && config.valid?
|
28
28
|
end
|
29
29
|
self.storage.sync if config && config.valid?
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
def warn(msg)
|
33
|
+
STDERR.puts msg
|
34
|
+
end
|
33
35
|
|
34
36
|
def log(msg)
|
35
|
-
|
37
|
+
STDOUT.puts msg if ENV["RAILS_GROUPS"] == "assets"
|
36
38
|
end
|
37
39
|
|
38
40
|
end
|
data/lib/asset_sync/engine.rb
CHANGED
@@ -7,10 +7,10 @@ class Engine < Rails::Engine
|
|
7
7
|
app_yaml = File.join(Rails.root, 'config/asset_sync.yml')
|
8
8
|
|
9
9
|
if File.exists?( app_initializer )
|
10
|
-
|
10
|
+
AssetSync.log "AssetSync: using #{app_initializer}"
|
11
11
|
load app_initializer
|
12
12
|
elsif !File.exists?( app_initializer ) && !File.exists?( app_yaml )
|
13
|
-
|
13
|
+
AssetSync.log "AssetSync: using default configuration from built-in initializer"
|
14
14
|
AssetSync.configure do |config|
|
15
15
|
config.fog_provider = ENV['FOG_PROVIDER']
|
16
16
|
config.fog_directory = ENV['FOG_DIRECTORY']
|
@@ -27,9 +27,9 @@ class Engine < Rails::Engine
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if File.exists?( app_yaml )
|
31
|
+
AssetSync.log "AssetSync: YAML file found #{app_yaml} settings will be merged into the configuration"
|
32
|
+
end
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
data/lib/asset_sync/storage.rb
CHANGED
@@ -18,6 +18,10 @@ module AssetSync
|
|
18
18
|
@bucket ||= connection.directories.get(self.config.fog_directory, :prefix => self.config.assets_prefix)
|
19
19
|
end
|
20
20
|
|
21
|
+
def log(msg)
|
22
|
+
AssetSync.log(msg)
|
23
|
+
end
|
24
|
+
|
21
25
|
def keep_existing_remote_files?
|
22
26
|
self.config.existing_remote_files?
|
23
27
|
end
|
@@ -34,13 +38,13 @@ module AssetSync
|
|
34
38
|
if self.config.manifest
|
35
39
|
if File.exists?(self.config.manifest_path)
|
36
40
|
yml = YAML.load(IO.read(self.config.manifest_path))
|
37
|
-
|
41
|
+
log "Using: Manifest #{self.config.manifest_path}"
|
38
42
|
return yml.values.map { |f| File.join(self.config.assets_prefix, f) }
|
39
43
|
else
|
40
|
-
|
44
|
+
log "Warning: manifest.yml not found at #{self.config.manifest_path}"
|
41
45
|
end
|
42
46
|
end
|
43
|
-
|
47
|
+
log "Using: Directory Search of #{path}/#{self.config.assets_prefix}"
|
44
48
|
Dir["#{path}/#{self.config.assets_prefix}/**/**"].map { |f| f[path.length+1,f.length-path.length] }
|
45
49
|
end
|
46
50
|
|
@@ -55,18 +59,18 @@ module AssetSync
|
|
55
59
|
|
56
60
|
def delete_file(f, remote_files_to_delete)
|
57
61
|
if remote_files_to_delete.include?(f.key)
|
58
|
-
|
62
|
+
log "Deleting: #{f.key}"
|
59
63
|
f.destroy
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
63
67
|
def delete_extra_remote_files
|
64
|
-
|
68
|
+
log "Fetching files to flag for delete"
|
65
69
|
remote_files = get_remote_files
|
66
70
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/19
|
67
71
|
from_remote_files_to_delete = remote_files - local_files
|
68
72
|
|
69
|
-
|
73
|
+
log "Flagging #{from_remote_files_to_delete.size} file(s) for deletion"
|
70
74
|
# Delete unneeded remote files
|
71
75
|
bucket.files.each do |f|
|
72
76
|
delete_file(f, from_remote_files_to_delete)
|
@@ -89,7 +93,7 @@ module AssetSync
|
|
89
93
|
if config.gzip? && File.extname(f) == ".gz"
|
90
94
|
# Don't bother uploading gzipped assets if we are in gzip_compression mode
|
91
95
|
# as we will overwrite file.css with file.css.gz if it exists.
|
92
|
-
|
96
|
+
log "Ignoring: #{f}"
|
93
97
|
ignore = true
|
94
98
|
elsif config.gzip? && File.exists?(gzipped)
|
95
99
|
original_size = File.size("#{path}/#{f}")
|
@@ -105,13 +109,13 @@ module AssetSync
|
|
105
109
|
:content_type => mime,
|
106
110
|
:content_encoding => 'gzip'
|
107
111
|
})
|
108
|
-
|
112
|
+
log "Uploading: #{gzipped} in place of #{f} saving #{percentage}%"
|
109
113
|
else
|
110
114
|
percentage = ((original_size.to_f/gzipped_size.to_f)*100).round(2)
|
111
|
-
|
115
|
+
log "Uploading: #{f} instead of #{gzipped} (compression increases this file by #{percentage}%)"
|
112
116
|
end
|
113
117
|
else
|
114
|
-
|
118
|
+
log "Uploading: #{f}"
|
115
119
|
end
|
116
120
|
|
117
121
|
file = bucket.files.create( file ) unless ignore
|
@@ -132,9 +136,10 @@ module AssetSync
|
|
132
136
|
|
133
137
|
def sync
|
134
138
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/19
|
135
|
-
|
136
|
-
|
137
|
-
|
139
|
+
log "AssetSync: Syncing."
|
140
|
+
upload_files
|
141
|
+
delete_extra_remote_files unless keep_existing_remote_files?
|
142
|
+
log "AssetSync: Done."
|
138
143
|
end
|
139
144
|
|
140
145
|
end
|
data/lib/asset_sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ date: 2012-03-07 00:00:00.000000000Z
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fog
|
18
|
-
requirement: &
|
18
|
+
requirement: &70246151754820 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70246151754820
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
|
-
requirement: &
|
29
|
+
requirement: &70246151754400 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *70246151754400
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &70246151753980 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *70246151753980
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: bundler
|
51
|
-
requirement: &
|
51
|
+
requirement: &70246151753560 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *70246151753560
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: jeweler
|
62
|
-
requirement: &
|
62
|
+
requirement: &70246151753140 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ! '>='
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *70246151753140
|
71
71
|
description: After you run assets:precompile your compiled assets will be synchronised
|
72
72
|
with your S3 bucket.
|
73
73
|
email:
|