asset_sync 0.3.2 → 0.4.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.
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/README.md +14 -2
- data/Rakefile +5 -0
- data/lib/asset_sync/config.rb +21 -4
- data/lib/asset_sync/engine.rb +4 -0
- data/lib/asset_sync/storage.rb +11 -2
- data/lib/asset_sync/version.rb +1 -1
- data/lib/generators/asset_sync/install_generator.rb +13 -1
- data/lib/generators/asset_sync/templates/asset_sync.rb +5 -1
- data/lib/generators/asset_sync/templates/asset_sync.yml +4 -0
- data/spec/asset_sync_spec.rb +6 -6
- data/spec/google_spec.rb +141 -0
- data/spec/google_with_yml/config/asset_sync.yml +19 -0
- data/spec/storage_spec.rb +40 -0
- metadata +18 -12
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](http://travis-ci.org/rumblelabs/asset_sync)
|
2
|
+
|
1
3
|
# Asset Sync
|
2
4
|
|
3
5
|
Synchronises Assets between Rails and S3.
|
@@ -179,10 +181,16 @@ defaults: &defaults
|
|
179
181
|
existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
|
180
182
|
# To delete existing remote files.
|
181
183
|
# existing_remote_files: delete
|
184
|
+
# To ignore existing remote files and overwrite.
|
185
|
+
# existing_remote_files: ignore
|
182
186
|
# Automatically replace files with their equivalent gzip compressed version
|
183
187
|
# gzip_compression: true
|
184
188
|
# Fail silently. Useful for environments such as Heroku
|
185
189
|
# fail_silently = true
|
190
|
+
# Always upload. Useful if you want to overwrite specific remote assets regardless of their existence
|
191
|
+
# eg: Static files in public often reference non-fingerprinted application.css
|
192
|
+
# note: You will still need to expire them from the CDN's edge cache locations
|
193
|
+
# always_upload: ['application.js', 'application.css']
|
186
194
|
|
187
195
|
development:
|
188
196
|
<<: *defaults
|
@@ -210,12 +218,12 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
|
|
210
218
|
|
211
219
|
#### AssetSync (optional)
|
212
220
|
|
213
|
-
* **existing_remote_files**: (`'keep', 'delete'`) what to do with previously precompiled files. **default:** `'keep'`
|
221
|
+
* **existing_remote_files**: (`'keep', 'delete', 'ignore'`) what to do with previously precompiled files. **default:** `'keep'`
|
214
222
|
* **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
|
215
223
|
* **manifest**: (`true, false`) when enabled, will use the `manifest.yml` generated by Rails to get the list of local files to upload. **experimental**. **default:** `'false'`
|
216
224
|
|
217
225
|
#### Fog (Required)
|
218
|
-
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files)
|
226
|
+
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage)
|
219
227
|
* **fog\_directory**: your bucket name
|
220
228
|
|
221
229
|
#### Fog (Optional)
|
@@ -232,6 +240,10 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
|
|
232
240
|
* **rackspace\_username**: your Rackspace username
|
233
241
|
* **rackspace\_api\_key**: your Rackspace API Key.
|
234
242
|
|
243
|
+
#### Google Storage
|
244
|
+
* **google\_storage\_access\_key\_id**: your Google Storage access key
|
245
|
+
* **google\_storage\_secret\_access\_key**: your Google Storage access secret
|
246
|
+
|
235
247
|
#### Rackspace (Optional)
|
236
248
|
|
237
249
|
* **rackspace\_auth\_url**: Rackspace auth URL, for Rackspace London use: lon.auth.api.rackspacecloud.com
|
data/Rakefile
CHANGED
data/lib/asset_sync/config.rb
CHANGED
@@ -9,6 +9,7 @@ module AssetSync
|
|
9
9
|
attr_accessor :gzip_compression
|
10
10
|
attr_accessor :manifest
|
11
11
|
attr_accessor :fail_silently
|
12
|
+
attr_accessor :always_upload
|
12
13
|
|
13
14
|
# FOG configuration
|
14
15
|
attr_accessor :fog_provider # Currently Supported ['AWS', 'Rackspace']
|
@@ -21,7 +22,10 @@ module AssetSync
|
|
21
22
|
# Rackspace
|
22
23
|
attr_accessor :rackspace_username, :rackspace_api_key, :rackspace_auth_url
|
23
24
|
|
24
|
-
|
25
|
+
# Google Storage
|
26
|
+
attr_accessor :google_storage_secret_access_key, :google_storage_access_key_id
|
27
|
+
|
28
|
+
validates :existing_remote_files, :inclusion => { :in => %w(keep delete ignore) }
|
25
29
|
|
26
30
|
validates :fog_provider, :presence => true
|
27
31
|
validates :fog_directory, :presence => true
|
@@ -30,6 +34,8 @@ module AssetSync
|
|
30
34
|
validates :aws_secret_access_key, :presence => true, :if => :aws?
|
31
35
|
validates :rackspace_username, :presence => true, :if => :rackspace?
|
32
36
|
validates :rackspace_api_key, :presence => true, :if => :rackspace?
|
37
|
+
validates :google_storage_secret_access_key, :presence => true, :if => :google?
|
38
|
+
validates :google_storage_access_key_id, :presence => true, :if => :google?
|
33
39
|
|
34
40
|
def initialize
|
35
41
|
self.fog_region = nil
|
@@ -37,6 +43,7 @@ module AssetSync
|
|
37
43
|
self.gzip_compression = false
|
38
44
|
self.manifest = false
|
39
45
|
self.fail_silently = false
|
46
|
+
self.always_upload = []
|
40
47
|
load_yml! if yml_exists?
|
41
48
|
end
|
42
49
|
|
@@ -51,7 +58,7 @@ module AssetSync
|
|
51
58
|
end
|
52
59
|
|
53
60
|
def existing_remote_files?
|
54
|
-
(self.existing_remote_files
|
61
|
+
['keep', 'ignore'].include?(self.existing_remote_files)
|
55
62
|
end
|
56
63
|
|
57
64
|
def aws?
|
@@ -66,6 +73,10 @@ module AssetSync
|
|
66
73
|
fog_provider == 'Rackspace'
|
67
74
|
end
|
68
75
|
|
76
|
+
def google?
|
77
|
+
fog_provider == 'Google'
|
78
|
+
end
|
79
|
+
|
69
80
|
def yml_exists?
|
70
81
|
File.exists?(self.yml_path)
|
71
82
|
end
|
@@ -92,10 +103,13 @@ module AssetSync
|
|
92
103
|
self.rackspace_username = yml["rackspace_username"]
|
93
104
|
self.rackspace_auth_url = yml["rackspace_auth_url"] if yml.has_key?("rackspace_auth_url")
|
94
105
|
self.rackspace_api_key = yml["rackspace_api_key"]
|
106
|
+
self.google_storage_secret_access_key = yml["google_storage_secret_access_key"]
|
107
|
+
self.google_storage_access_key_id = yml["google_storage_access_key_id"]
|
95
108
|
self.existing_remote_files = yml["existing_remote_files"] if yml.has_key?("existing_remote_files")
|
96
109
|
self.gzip_compression = yml["gzip_compression"] if yml.has_key?("gzip_compression")
|
97
110
|
self.manifest = yml["manifest"] if yml.has_key?("manifest")
|
98
111
|
self.fail_silently = yml["fail_silently"] if yml.has_key?("fail_silently")
|
112
|
+
self.always_upload = yml["always_upload"] if yml.has_key?("always_upload")
|
99
113
|
|
100
114
|
# TODO deprecate the other old style config settings. FML.
|
101
115
|
self.aws_access_key_id = yml["aws_access_key"] if yml.has_key?("aws_access_key")
|
@@ -123,9 +137,12 @@ module AssetSync
|
|
123
137
|
:rackspace_username => rackspace_username,
|
124
138
|
:rackspace_api_key => rackspace_api_key
|
125
139
|
})
|
126
|
-
|
127
140
|
options.merge!({ :rackspace_auth_url => rackspace_auth_url }) if rackspace_auth_url
|
128
|
-
|
141
|
+
elsif google?
|
142
|
+
options.merge!({
|
143
|
+
:google_storage_secret_access_key => google_storage_secret_access_key,
|
144
|
+
:google_storage_access_key_id => google_storage_access_key_id
|
145
|
+
})
|
129
146
|
else
|
130
147
|
raise ArgumentError, "AssetSync Unknown provider: #{fog_provider} only AWS and Rackspace are supported currently."
|
131
148
|
end
|
data/lib/asset_sync/engine.rb
CHANGED
@@ -21,6 +21,10 @@ class Engine < Rails::Engine
|
|
21
21
|
|
22
22
|
config.rackspace_username = ENV['RACKSPACE_USERNAME']
|
23
23
|
config.rackspace_api_key = ENV['RACKSPACE_API_KEY']
|
24
|
+
|
25
|
+
config.google_storage_access_key_id = ENV['GOOGLE_STORAGE_ACCESS_KEY_ID']
|
26
|
+
config.google_storage_secret_access_key = ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY']
|
27
|
+
|
24
28
|
config.existing_remote_files = ENV['ASSET_SYNC_EXISTING_REMOTE_FILES'] || "keep"
|
25
29
|
config.gzip_compression = ENV['ASSET_SYNC_GZIP_COMPRESSION'] == 'true'
|
26
30
|
config.manifest = ENV['ASSET_SYNC_MANIFEST'] == 'true'
|
data/lib/asset_sync/storage.rb
CHANGED
@@ -34,6 +34,10 @@ module AssetSync
|
|
34
34
|
@local_files ||= get_local_files
|
35
35
|
end
|
36
36
|
|
37
|
+
def always_upload_files
|
38
|
+
self.config.always_upload.map { |f| File.join(self.config.assets_prefix, f) }
|
39
|
+
end
|
40
|
+
|
37
41
|
def get_local_files
|
38
42
|
if self.config.manifest
|
39
43
|
if File.exists?(self.config.manifest_path)
|
@@ -132,9 +136,9 @@ module AssetSync
|
|
132
136
|
|
133
137
|
def upload_files
|
134
138
|
# get a fresh list of remote files
|
135
|
-
remote_files = get_remote_files
|
139
|
+
remote_files = ignore_existing_remote_files? ? [] : get_remote_files
|
136
140
|
# fixes: https://github.com/rumblelabs/asset_sync/issues/19
|
137
|
-
local_files_to_upload = local_files - remote_files
|
141
|
+
local_files_to_upload = local_files - remote_files + always_upload_files
|
138
142
|
|
139
143
|
# Upload new files
|
140
144
|
local_files_to_upload.each do |f|
|
@@ -151,5 +155,10 @@ module AssetSync
|
|
151
155
|
log "AssetSync: Done."
|
152
156
|
end
|
153
157
|
|
158
|
+
private
|
159
|
+
|
160
|
+
def ignore_existing_remote_files?
|
161
|
+
self.config.existing_remote_files == 'ignore'
|
162
|
+
end
|
154
163
|
end
|
155
164
|
end
|
data/lib/asset_sync/version.rb
CHANGED
@@ -5,7 +5,7 @@ module AssetSync
|
|
5
5
|
|
6
6
|
# Commandline options can be defined here using Thor-like options:
|
7
7
|
class_option :use_yml, :type => :boolean, :default => false, :desc => "Use YML file instead of Rails Initializer"
|
8
|
-
class_option :provider, :type => :string, :default => "AWS", :desc => "Generate with support for 'AWS' or '
|
8
|
+
class_option :provider, :type => :string, :default => "AWS", :desc => "Generate with support for 'AWS', 'Rackspace', or 'Google'"
|
9
9
|
|
10
10
|
def self.source_root
|
11
11
|
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
@@ -15,6 +15,10 @@ module AssetSync
|
|
15
15
|
options[:provider] == 'AWS'
|
16
16
|
end
|
17
17
|
|
18
|
+
def google?
|
19
|
+
options[:provider] == 'Google'
|
20
|
+
end
|
21
|
+
|
18
22
|
def rackspace?
|
19
23
|
options[:provider] == 'Rackspace'
|
20
24
|
end
|
@@ -27,6 +31,14 @@ module AssetSync
|
|
27
31
|
"<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
|
28
32
|
end
|
29
33
|
|
34
|
+
def google_storage_access_key_id
|
35
|
+
"<%= ENV['GOOGLE_STORAGE_ACCESS_KEY_ID'] %>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def google_storage_secret_access_key
|
39
|
+
"<%= ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY'] %>"
|
40
|
+
end
|
41
|
+
|
30
42
|
def rackspace_username
|
31
43
|
"<%= ENV['RACKSPACE_USERNAME'] %>"
|
32
44
|
end
|
@@ -3,6 +3,10 @@ AssetSync.configure do |config|
|
|
3
3
|
config.fog_provider = 'AWS'
|
4
4
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
5
5
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
6
|
+
<%- elsif google? -%>
|
7
|
+
config.fog_provider = 'Google'
|
8
|
+
config.google_storage_access_key_id = ENV['GOOGLE_STORAGE_ACCESS_KEY_ID']
|
9
|
+
config.google_storage_secret_access_key = ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY']
|
6
10
|
<%- elsif rackspace? -%>
|
7
11
|
config.fog_provider = 'Rackspace'
|
8
12
|
config.rackspace_username = ENV['RACKSPACE_USERNAME']
|
@@ -28,4 +32,4 @@ AssetSync.configure do |config|
|
|
28
32
|
#
|
29
33
|
# Fail silently. Useful for environments such as Heroku
|
30
34
|
# config.fail_silently = true
|
31
|
-
end
|
35
|
+
end
|
@@ -3,6 +3,10 @@ defaults: &defaults
|
|
3
3
|
fog_provider: 'AWS'
|
4
4
|
aws_access_key_id: "<%= aws_access_key_id %>"
|
5
5
|
aws_secret_access_key: "<%= aws_secret_access_key %>"
|
6
|
+
<%- elsif google? -%>
|
7
|
+
fog_provider: 'Google'
|
8
|
+
google_storage_access_key_id: "<%= google_storage_access_key_id %>"
|
9
|
+
google_storage_secret_access_key: "<%= google_storage_secret_access_key %>"
|
6
10
|
<%- elsif rackspace? -%>
|
7
11
|
fog_provider: 'Rackspace'
|
8
12
|
rackspace_username: "<%= rackspace_username %>"
|
data/spec/asset_sync_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe AssetSync do
|
|
29
29
|
AssetSync.config.aws_access_key_id.should == "aaaa"
|
30
30
|
end
|
31
31
|
|
32
|
-
it "should configure
|
32
|
+
it "should configure aws_secret_access_key" do
|
33
33
|
AssetSync.config.aws_secret_access_key.should == "bbbb"
|
34
34
|
end
|
35
35
|
|
@@ -37,11 +37,11 @@ describe AssetSync do
|
|
37
37
|
AssetSync.config.fog_directory.should == "mybucket"
|
38
38
|
end
|
39
39
|
|
40
|
-
it "should configure
|
40
|
+
it "should configure fog_region" do
|
41
41
|
AssetSync.config.fog_region.should == "eu-west-1"
|
42
42
|
end
|
43
43
|
|
44
|
-
it "should configure
|
44
|
+
it "should configure existing_remote_files" do
|
45
45
|
AssetSync.config.existing_remote_files.should == "keep"
|
46
46
|
end
|
47
47
|
|
@@ -68,15 +68,15 @@ describe AssetSync do
|
|
68
68
|
AssetSync.config.aws_secret_access_key.should == "zzzz"
|
69
69
|
end
|
70
70
|
|
71
|
-
it "should configure
|
71
|
+
it "should configure fog_directory" do
|
72
72
|
AssetSync.config.fog_directory.should == "rails_app_test"
|
73
73
|
end
|
74
74
|
|
75
|
-
it "should configure
|
75
|
+
it "should configure fog_region" do
|
76
76
|
AssetSync.config.fog_region.should == "eu-west-1"
|
77
77
|
end
|
78
78
|
|
79
|
-
it "should configure
|
79
|
+
it "should configure existing_remote_files" do
|
80
80
|
AssetSync.config.existing_remote_files.should == "keep"
|
81
81
|
end
|
82
82
|
|
data/spec/google_spec.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe AssetSync do
|
4
|
+
include_context "mock Rails without_yml"
|
5
|
+
|
6
|
+
describe 'with initializer' do
|
7
|
+
before(:each) do
|
8
|
+
AssetSync.config = AssetSync::Config.new
|
9
|
+
AssetSync.configure do |config|
|
10
|
+
config.fog_provider = 'Google'
|
11
|
+
config.google_storage_access_key_id = 'aaaa'
|
12
|
+
config.google_storage_secret_access_key = 'bbbb'
|
13
|
+
config.fog_directory = 'mybucket'
|
14
|
+
config.existing_remote_files = "keep"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should configure provider as Google" do
|
19
|
+
AssetSync.config.fog_provider.should == 'Google'
|
20
|
+
AssetSync.config.should be_google
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should should keep existing remote files" do
|
24
|
+
AssetSync.config.existing_remote_files?.should == true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should configure google_storage_access_key_id" do
|
28
|
+
AssetSync.config.google_storage_access_key_id.should == "aaaa"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should configure google_storage_secret_access_key" do
|
32
|
+
AssetSync.config.google_storage_secret_access_key.should == "bbbb"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should configure fog_directory" do
|
36
|
+
AssetSync.config.fog_directory.should == "mybucket"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should configure existing_remote_files" do
|
40
|
+
AssetSync.config.existing_remote_files.should == "keep"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should default gzip_compression to false" do
|
44
|
+
AssetSync.config.gzip_compression.should be_false
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should default manifest to false" do
|
48
|
+
AssetSync.config.manifest.should be_false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'from yml' do
|
53
|
+
before(:each) do
|
54
|
+
set_rails_root('google_with_yml')
|
55
|
+
AssetSync.config = AssetSync::Config.new
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should configure google_storage_access_key_id" do
|
59
|
+
AssetSync.config.google_storage_access_key_id.should == "xxxx"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should configure google_storage_secret_access_key" do
|
63
|
+
AssetSync.config.google_storage_secret_access_key.should == "zzzz"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should configure google_storage_access_key" do
|
67
|
+
AssetSync.config.fog_directory.should == "rails_app_test"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should configure google_storage_access_key" do
|
71
|
+
AssetSync.config.existing_remote_files.should == "keep"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should default gzip_compression to false" do
|
75
|
+
AssetSync.config.gzip_compression.should be_false
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should default manifest to false" do
|
79
|
+
AssetSync.config.manifest.should be_false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'with no configuration' do
|
84
|
+
before(:each) do
|
85
|
+
AssetSync.config = AssetSync::Config.new
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should be invalid" do
|
89
|
+
lambda{ AssetSync.sync }.should raise_error(AssetSync::Config::Invalid)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'with fail_silent configuration' do
|
94
|
+
before(:each) do
|
95
|
+
AssetSync.config = AssetSync::Config.new
|
96
|
+
AssetSync.configure do |config|
|
97
|
+
config.fail_silently = true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not raise an invalid exception" do
|
102
|
+
lambda{ AssetSync.sync }.should_not raise_error(AssetSync::Config::Invalid)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe 'with gzip_compression enabled' do
|
107
|
+
before(:each) do
|
108
|
+
AssetSync.config = AssetSync::Config.new
|
109
|
+
AssetSync.config.gzip_compression = true
|
110
|
+
end
|
111
|
+
|
112
|
+
it "config.gzip? should be true" do
|
113
|
+
AssetSync.config.gzip?.should be_true
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'with manifest enabled' do
|
118
|
+
before(:each) do
|
119
|
+
AssetSync.config = AssetSync::Config.new
|
120
|
+
AssetSync.config.manifest = true
|
121
|
+
end
|
122
|
+
|
123
|
+
it "config.manifest should be true" do
|
124
|
+
AssetSync.config.manifest.should be_true
|
125
|
+
end
|
126
|
+
|
127
|
+
it "config.manifest_path should default to public/assets.." do
|
128
|
+
AssetSync.config.manifest_path.should =~ /public\/assets\/manifest.yml/
|
129
|
+
end
|
130
|
+
|
131
|
+
it "config.manifest_path should default to public/assets.." do
|
132
|
+
Rails.application.config.assets.manifest = "/var/assets"
|
133
|
+
AssetSync.config.manifest_path.should == "/var/assets/manifest.yml"
|
134
|
+
end
|
135
|
+
|
136
|
+
it "config.manifest_path should default to public/custom_assets.." do
|
137
|
+
Rails.application.config.assets.prefix = 'custom_assets'
|
138
|
+
AssetSync.config.manifest_path.should =~ /public\/custom_assets\/manifest.yml/
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
fog_provider: "Google"
|
3
|
+
google_storage_access_key_id: 'xxxx'
|
4
|
+
google_storage_secret_access_key: 'zzzz'
|
5
|
+
|
6
|
+
development:
|
7
|
+
<<: *defaults
|
8
|
+
fog_directory: "rails_app_development"
|
9
|
+
existing_remote_files: keep
|
10
|
+
|
11
|
+
test:
|
12
|
+
<<: *defaults
|
13
|
+
fog_directory: "rails_app_test"
|
14
|
+
existing_remote_files: keep
|
15
|
+
|
16
|
+
production:
|
17
|
+
<<: *defaults
|
18
|
+
fog_directory: "rails_app_production"
|
19
|
+
existing_remote_files: delete
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe AssetSync::Storage do
|
5
|
+
include_context "mock Rails without_yml"
|
6
|
+
|
7
|
+
describe '#upload_files' do
|
8
|
+
before(:each) do
|
9
|
+
@local_files = ["local_image2.jpg", "local_image1.jpg", "local_stylesheet1.css", "local_stylesheet2.css"]
|
10
|
+
@remote_files = ["local_image.jpg", "local_stylesheet1.css"]
|
11
|
+
@config = AssetSync::Config.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should overwrite all remote files if set to ignore' do
|
15
|
+
@config.existing_remote_files = 'ignore'
|
16
|
+
storage = AssetSync::Storage.new(@config)
|
17
|
+
storage.stub(:local_files).and_return(@local_files)
|
18
|
+
File.stub(:file?).and_return(true) # Pretend they all exist
|
19
|
+
|
20
|
+
@local_files.each do |file|
|
21
|
+
storage.should_receive(:upload_file).with(file)
|
22
|
+
end
|
23
|
+
storage.upload_files
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should allow force overwriting of specific files' do
|
27
|
+
@config.always_upload = ['local_image.jpg']
|
28
|
+
|
29
|
+
storage = AssetSync::Storage.new(@config)
|
30
|
+
storage.stub(:local_files).and_return(@local_files)
|
31
|
+
storage.stub(:get_remote_files).and_return(@remote_files)
|
32
|
+
File.stub(:file?).and_return(true) # Pretend they all exist
|
33
|
+
|
34
|
+
(@local_files - @remote_files + storage.always_upload_files).each do |file|
|
35
|
+
storage.should_receive(:upload_file).with(file)
|
36
|
+
end
|
37
|
+
storage.upload_files
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ date: 2012-04-18 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: fog
|
18
|
-
requirement: &
|
18
|
+
requirement: &70252796863900 !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: *70252796863900
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
|
-
requirement: &
|
29
|
+
requirement: &70252796862460 !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: *70252796862460
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &70252796896120 !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: *70252796896120
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: bundler
|
51
|
-
requirement: &
|
51
|
+
requirement: &70252796894920 !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: *70252796894920
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: jeweler
|
62
|
-
requirement: &
|
62
|
+
requirement: &70252796893900 !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: *70252796893900
|
71
71
|
description: After you run assets:precompile your compiled assets will be synchronised
|
72
72
|
with your S3 bucket.
|
73
73
|
email:
|
@@ -79,6 +79,7 @@ extensions: []
|
|
79
79
|
extra_rdoc_files: []
|
80
80
|
files:
|
81
81
|
- .gitignore
|
82
|
+
- .travis.yml
|
82
83
|
- Gemfile
|
83
84
|
- README.md
|
84
85
|
- Rakefile
|
@@ -97,9 +98,12 @@ files:
|
|
97
98
|
- lib/tasks/asset_sync.rake
|
98
99
|
- spec/asset_sync_spec.rb
|
99
100
|
- spec/aws_with_yml/config/asset_sync.yml
|
101
|
+
- spec/google_spec.rb
|
102
|
+
- spec/google_with_yml/config/asset_sync.yml
|
100
103
|
- spec/rackspace_spec.rb
|
101
104
|
- spec/rackspace_with_yml/config/asset_sync.yml
|
102
105
|
- spec/spec_helper.rb
|
106
|
+
- spec/storage_spec.rb
|
103
107
|
homepage: https://github.com/rumblelabs/asset_sync
|
104
108
|
licenses: []
|
105
109
|
post_install_message:
|
@@ -128,7 +132,9 @@ summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront a
|
|
128
132
|
test_files:
|
129
133
|
- spec/asset_sync_spec.rb
|
130
134
|
- spec/aws_with_yml/config/asset_sync.yml
|
135
|
+
- spec/google_spec.rb
|
136
|
+
- spec/google_with_yml/config/asset_sync.yml
|
131
137
|
- spec/rackspace_spec.rb
|
132
138
|
- spec/rackspace_with_yml/config/asset_sync.yml
|
133
139
|
- spec/spec_helper.rb
|
134
|
-
|
140
|
+
- spec/storage_spec.rb
|