asset_sync 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/asset_sync.gemspec +1 -1
- data/lib/asset_sync/asset_sync.rb +6 -2
- data/lib/asset_sync/config.rb +3 -0
- data/lib/asset_sync/storage.rb +21 -2
- data/lib/asset_sync/version.rb +1 -1
- data/spec/asset_sync_spec.rb +6 -0
- data/spec/google_spec.rb +1 -0
- data/spec/storage_spec.rb +14 -0
- metadata +12 -12
data/README.md
CHANGED
@@ -191,6 +191,8 @@ defaults: &defaults
|
|
191
191
|
# eg: Static files in public often reference non-fingerprinted application.css
|
192
192
|
# note: You will still need to expire them from the CDN's edge cache locations
|
193
193
|
# always_upload: ['application.js', 'application.css']
|
194
|
+
# Ignored files. Useful if there are some files that are created dynamically on the server and you don't want to upload on deploy.
|
195
|
+
# ignored_files: ['ignore_me.js', %r(ignore_some/\d{32}\.css)]
|
194
196
|
|
195
197
|
development:
|
196
198
|
<<: *defaults
|
data/asset_sync.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "asset_sync/version"
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "asset_sync"
|
8
8
|
s.version = AssetSync::VERSION
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-06-02"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.authors = ["Simon Hamilton", "David Rice", "Phil McClure"]
|
12
12
|
s.email = ["shamilton@rumblelabs.com", "me@davidjrice.co.uk", "pmcclure@rumblelabs.com"]
|
@@ -32,17 +32,21 @@ module AssetSync
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def warn(msg)
|
35
|
-
|
35
|
+
stderr.puts msg
|
36
36
|
end
|
37
37
|
|
38
38
|
def log(msg)
|
39
|
-
|
39
|
+
stdout.puts msg if ENV["RAILS_GROUPS"] == "assets"
|
40
40
|
end
|
41
41
|
|
42
42
|
def enabled?
|
43
43
|
config.enabled?
|
44
44
|
end
|
45
45
|
|
46
|
+
# easier to stub
|
47
|
+
def stderr ; STDERR ; end
|
48
|
+
def stdout ; STDOUT ; end
|
49
|
+
|
46
50
|
end
|
47
51
|
|
48
52
|
end
|
data/lib/asset_sync/config.rb
CHANGED
@@ -10,6 +10,7 @@ module AssetSync
|
|
10
10
|
attr_accessor :manifest
|
11
11
|
attr_accessor :fail_silently
|
12
12
|
attr_accessor :always_upload
|
13
|
+
attr_accessor :ignored_files
|
13
14
|
attr_accessor :enabled
|
14
15
|
|
15
16
|
# FOG configuration
|
@@ -45,6 +46,7 @@ module AssetSync
|
|
45
46
|
self.manifest = false
|
46
47
|
self.fail_silently = false
|
47
48
|
self.always_upload = []
|
49
|
+
self.ignored_files = []
|
48
50
|
self.enabled = true
|
49
51
|
load_yml! if yml_exists?
|
50
52
|
end
|
@@ -117,6 +119,7 @@ module AssetSync
|
|
117
119
|
self.manifest = yml["manifest"] if yml.has_key?("manifest")
|
118
120
|
self.fail_silently = yml["fail_silently"] if yml.has_key?("fail_silently")
|
119
121
|
self.always_upload = yml["always_upload"] if yml.has_key?("always_upload")
|
122
|
+
self.ignored_files = yml["ignored_files"] if yml.has_key?("ignored_files")
|
120
123
|
|
121
124
|
# TODO deprecate the other old style config settings. FML.
|
122
125
|
self.aws_access_key_id = yml["aws_access_key"] if yml.has_key?("aws_access_key")
|
data/lib/asset_sync/storage.rb
CHANGED
@@ -30,6 +30,25 @@ module AssetSync
|
|
30
30
|
Rails.public_path
|
31
31
|
end
|
32
32
|
|
33
|
+
def ignored_files
|
34
|
+
files = []
|
35
|
+
Array(self.config.ignored_files).each do |ignore|
|
36
|
+
case ignore
|
37
|
+
when Regexp
|
38
|
+
files += self.local_files.select do |file|
|
39
|
+
file =~ ignore
|
40
|
+
end
|
41
|
+
when String
|
42
|
+
files += self.local_files.select do |file|
|
43
|
+
file.split('/').last == ignore
|
44
|
+
end
|
45
|
+
else
|
46
|
+
log "Error: please define ignored_files as string or regular expression. #{ignore} (#{ignore.class}) ignored."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
files.uniq
|
50
|
+
end
|
51
|
+
|
33
52
|
def local_files
|
34
53
|
@local_files ||= get_local_files
|
35
54
|
end
|
@@ -74,7 +93,7 @@ module AssetSync
|
|
74
93
|
log "Fetching files to flag for delete"
|
75
94
|
remote_files = get_remote_files
|
76
95
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/19
|
77
|
-
from_remote_files_to_delete = remote_files - local_files
|
96
|
+
from_remote_files_to_delete = remote_files - local_files - ignored_files
|
78
97
|
|
79
98
|
log "Flagging #{from_remote_files_to_delete.size} file(s) for deletion"
|
80
99
|
# Delete unneeded remote files
|
@@ -138,7 +157,7 @@ module AssetSync
|
|
138
157
|
# get a fresh list of remote files
|
139
158
|
remote_files = ignore_existing_remote_files? ? [] : get_remote_files
|
140
159
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/19
|
141
|
-
local_files_to_upload = local_files - remote_files + always_upload_files
|
160
|
+
local_files_to_upload = local_files - ignored_files - remote_files + always_upload_files
|
142
161
|
|
143
162
|
# Upload new files
|
144
163
|
local_files_to_upload.each do |f|
|
data/lib/asset_sync/version.rb
CHANGED
data/spec/asset_sync_spec.rb
CHANGED
@@ -140,6 +140,7 @@ describe AssetSync do
|
|
140
140
|
|
141
141
|
describe 'with fail_silent configuration' do
|
142
142
|
before(:each) do
|
143
|
+
AssetSync.stub(:stderr).and_return(@stderr = StringIO.new)
|
143
144
|
AssetSync.config = AssetSync::Config.new
|
144
145
|
AssetSync.configure do |config|
|
145
146
|
config.fail_silently = true
|
@@ -149,6 +150,11 @@ describe AssetSync do
|
|
149
150
|
it "should not raise an invalid exception" do
|
150
151
|
lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
|
151
152
|
end
|
153
|
+
|
154
|
+
it "should output a warning to stderr" do
|
155
|
+
AssetSync.sync
|
156
|
+
@stderr.string.should =~ /can't be blank/
|
157
|
+
end
|
152
158
|
end
|
153
159
|
|
154
160
|
describe 'with gzip_compression enabled' do
|
data/spec/google_spec.rb
CHANGED
data/spec/storage_spec.rb
CHANGED
@@ -36,5 +36,19 @@ describe AssetSync::Storage do
|
|
36
36
|
end
|
37
37
|
storage.upload_files
|
38
38
|
end
|
39
|
+
|
40
|
+
it 'should allow to ignore files' do
|
41
|
+
@config.ignored_files = ['local_image1.jpg', /local_stylesheet\d\.css/]
|
42
|
+
|
43
|
+
storage = AssetSync::Storage.new(@config)
|
44
|
+
storage.stub(:local_files).and_return(@local_files)
|
45
|
+
storage.stub(:get_remote_files).and_return(@remote_files)
|
46
|
+
File.stub(:file?).and_return(true) # Pretend they all exist
|
47
|
+
|
48
|
+
(@local_files - @remote_files - storage.ignored_files + storage.always_upload_files).each do |file|
|
49
|
+
storage.should_receive(:upload_file).with(file)
|
50
|
+
end
|
51
|
+
storage.upload_files
|
52
|
+
end
|
39
53
|
end
|
40
54
|
end
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fog
|
18
|
-
requirement: &
|
18
|
+
requirement: &70223412035340 !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: *70223412035340
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
|
-
requirement: &
|
29
|
+
requirement: &70223412034660 !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: *70223412034660
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &70223412033020 !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: *70223412033020
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: bundler
|
51
|
-
requirement: &
|
51
|
+
requirement: &70223412032060 !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: *70223412032060
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: jeweler
|
62
|
-
requirement: &
|
62
|
+
requirement: &70223412031120 !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: *70223412031120
|
71
71
|
description: After you run assets:precompile your compiled assets will be synchronised
|
72
72
|
with your S3 bucket.
|
73
73
|
email:
|