asset_sync 0.2.9 → 0.3.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/README.md CHANGED
@@ -9,168 +9,216 @@ This was initially built and is intended to work on [Heroku](http://heroku.com)
9
9
 
10
10
  ## Upgrading?
11
11
 
12
- If you are upgrading from a version of asset_sync **< 0.2.0** (i.e. 0.1.x). All of the references to config variables have changed to reference those used in **Fog**. Ensure to backup your `asset\_sync.rb` or `asset\_sync.yml` files and re-run the generator. You may also then need to update your ENV configuration variables (or you can change the ones that are referenced).
12
+ If you are upgrading from a version of asset_sync **< 0.2.0** (i.e. 0.1.x). All of the references to config variables have changed to reference those used in **Fog**. Ensure to backup your `asset_sync.rb` or `asset_sync.yml` files and re-run the generator. You may also then need to update your ENV configuration variables (or you can change the ones that are referenced).
13
13
 
14
- ## KNOWN ISSUES (IMPORTANT)
14
+ ## Heroku Labs (BETA)
15
15
 
16
- We are currently trying to talk with Heroku to iron these out.
16
+ Previously there were [several issues](http://github.com/rumblelabs/asset_sync/blob/master/docs/heroku.md) with using asset_sync on Heroku as described in our [Heroku dev centre article](http://devcenter.heroku.com/articles/cdn-asset-host-rails31).
17
17
 
18
- 1. Will not work on heroku on an application with a *RAILS_ENV* configured as anything other than production
19
- 2. Will not work on heroku using ENV variables with the configuration as described below, you must hardcode all variables
18
+ Now to get everything working smoothly with using **ENV** variables to configure `asset_sync` we just need to enable the [user\_env\_compile](http://devcenter.heroku.com/articles/labs-user-env-compile) functionality. In short:
20
19
 
21
- ### 1. RAILS_ENV
20
+ heroku plugins:install https://github.com/heroku/heroku-labs.git
21
+ heroku labs:enable user_env_compile -a myapp
22
22
 
23
- When you see `rake assets:precompile` during deployment. Heroku is actually running something like
23
+ Hopefully this will make it's way into the platform as standard.
24
24
 
25
- env RAILS_ENV=production DATABASE_URL=scheme://user:pass@127.0.0.1/dbname bundle exec rake assets:precompile 2>&1
25
+ ## Installation
26
26
 
27
- This means the *RAILS_ENV* you have set via *heroku:config* is not used.
27
+ Add the gem to your Gemfile
28
28
 
29
- **Workaround:** you could have just one S3 bucket dedicated to assets and ensure to set keep the existing remote files
29
+ ``` ruby
30
+ gem "asset_sync"
31
+ ```
30
32
 
31
- AssetSync.configure do |config|
32
- ...
33
- config.fog_directory = 'app-assets'
34
- config.existing_remote_files = "keep"
35
- end
33
+ If you want, you can put it within your **:assets** group in your Gemfile.
36
34
 
37
- ### 2. ENV varables not available
35
+ ``` ruby
36
+ group :assets do
37
+ gem 'sass-rails', '~> 3.2.3'
38
+ gem 'coffee-rails', '~> 3.2.1'
39
+ gem 'uglifier', '>= 1.0.3'
40
+ gem "asset_sync"
41
+ end
42
+ ```
38
43
 
39
- Currently when heroku runs `rake assets:precompile` during deployment. It does not load your Rails application's environment config. This means using any **ENV** variables you could normally depend on are not available. For now you can just run `heroku run rake assets:precompile` after deploy.
44
+ This is good practice when pre-compiling your assets as it will reduce load time and server memory in production. The only caveat being, you may not be able to use a custom initializer, without perhaps wrapping it with.
40
45
 
41
- **Workaround:** you could just hardcode your AWS credentials in the initializer or yml
46
+ ``` ruby
47
+ defined?(AssetSync) do
48
+ ...
49
+ end
50
+ ```
42
51
 
43
- AssetSync.configure do |config|
44
- config.aws_access_key_id = 'xxx'
45
- config.aws_secret_access_key = 'xxx'
46
- config.fog_directory = 'mybucket'
47
- end
52
+ ## Configuration
48
53
 
49
- ## Installation
54
+ ### Rails
50
55
 
51
- Add the gem to your Gemfile
56
+ Configure __config/environments/production.rb__ to use Amazon
57
+ S3 as the asset host and ensure precompiling is enabled.
52
58
 
53
- gem "asset_sync"
54
59
 
55
- > The following steps are now optional as of version **0.1.7** there is a built-in initializer [lib/engine.rb](https://github.com/rumblelabs/asset_sync/blob/master/lib/asset_sync/engine.rb)
60
+ ``` ruby
61
+ #config/environments/production.rb
62
+ config.action_controller.asset_host = Proc.new do |source, request|
63
+ request.ssl? ? "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com" : "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
64
+ end
65
+ ```
56
66
 
57
- Generate the rake task and config file
67
+ Also, ensure the following are defined (in production.rb or application.rb)
58
68
 
59
- rails g asset_sync:install
60
-
61
- If you would like to use a YAML file for configuration instead of the default (Rails Initializer) then
69
+ * **config.assets.digest** is set to **true**.
70
+ * **config.assets.enabled** is set to **true**.
62
71
 
63
- rails g asset_sync:install --use-yml
72
+ ### AssetSync
64
73
 
65
- The default *provider* is `AWS` but you can pick which one you need.
74
+ **AssetSync** supports the following methods of configuration.
66
75
 
67
- rails g asset_sync:install --provider=Rackspace
68
- rails g asset_sync:install --provider=AWS
76
+ * [Built-in Initializer](/rumblelabs/asset_sync/blob/master/lib/asset_sync/engine.rb) (configured through environment variables)
77
+ * Rails Initializer
78
+ * A YAML config file
69
79
 
70
- ## Configuration
71
80
 
72
- Configure __config/environments/production.rb__ to use Amazon
73
- S3 as the asset host and ensure precompiling is enabled.
81
+ Using the **Built-in Initializer** is the default method and is supposed to be used with **environment** variables. It's the recommended approach for deployments on Heroku.
74
82
 
75
- # config/environments/production.rb
76
- config.action_controller.asset_host = Proc.new do |source, request|
77
- request.ssl? ? "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com" : "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
78
- end
83
+ If you need more control over configuration you will want to use a **custom rails initializer**.
79
84
 
80
- We support two methods of configuration.
85
+ Configuration using a **YAML** file (a common strategy for Capistrano deployments) is also suppored.
81
86
 
82
- * Rails Initializer
83
- * A YAML config file
87
+ The recommend way to configure **asset_sync** is by using **environment variables** however it's up to you, it will work fine if you hard code them too. The main reason is that then your access keys are not checked into version control.
84
88
 
85
- Using an **Initializer** is the default method and is best used with **environment** variables. It's the recommended approach for deployments on Heroku.
89
+ ### Built-in Initializer (Environment Variables)
86
90
 
87
- Using a **YAML** config file is a traditional strategy for Capistrano deployments. If you are using [Moonshine](https://github.com/railsmachine/moonshine) (which we would recommend) then it is best used with [shared configuration files](https://github.com/railsmachine/moonshine/wiki/Shared-Configuration-Files).
91
+ The Built-in Initializer will configure **AssetSync** based on the contents of your environment variables.
88
92
 
89
- The recommend way to configure **asset_sync** is by using environment variables however it's up to you, it will work fine if you hard code them too. The main reason is that then your access keys are not checked into version control.
93
+ Add your configuration details to **heroku**
90
94
 
91
- ### Initializer (config/initializers/asset_sync.rb)
95
+ ``` bash
96
+ heroku config:add AWS_ACCESS_KEY_ID=xxxx
97
+ heroku config:add AWS_SECRET_ACCESS_KEY=xxxx
98
+ heroku config:add FOG_DIRECTORY=xxxx
99
+ heroku config:add FOG_PROVIDER=AWS
100
+ # and optionally:
101
+ heroku config:add FOG_REGION=eu-west-1
102
+ heroku config:add ASSET_SYNC_GZIP_COMPRESSION=true
103
+ heroku config:add ASSET_SYNC_MANIFEST=true
104
+ heroku config:add ASSET_SYNC_EXISTING_REMOTE_FILES=keep
105
+ ```
92
106
 
93
- The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
107
+ Or add to a traditional unix system
94
108
 
95
- AssetSync.configure do |config|
96
- config.fog_provider = 'AWS'
97
- config.fog_directory = ENV['FOG_DIRECTORY']
98
- config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
99
- config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
100
-
101
- # Don't delete files from the store
102
- # config.existing_remote_files = "keep"
103
- #
104
- # Increase upload performance by configuring your region
105
- # config.fog_region = 'eu-west-1'
106
- #
107
- # Automatically replace files with their equivalent gzip compressed version
108
- # config.gzip_compression = true
109
- #
110
- # Use the Rails generated 'manifest.yml' file to produce the list of files to
111
- # upload instead of searching the assets directory.
112
- # config.manifest = true
113
- #
114
- # Fail silently. Useful for environments such as Heroku
115
- # config.fail_silently = true
116
- end
109
+ ``` bash
110
+ export AWS_ACCESS_KEY_ID=xxxx
111
+ export AWS_SECRET_ACCESS_KEY=xxxx
112
+ export FOG_DIRECTORY=xxxx
113
+ ```
117
114
 
115
+ Rackspace configuration is also supported
118
116
 
119
- ### YAML (config/asset_sync.yml)
117
+ ``` bash
118
+ heroku config:add RACKSPACE_USERNAME=xxxx
119
+ heroku config:add RACKSPACE_API_KEY=xxxx
120
+ heroku config:add FOG_DIRECTORY=xxxx
121
+ heroku config:add FOG_PROVIDER=Rackspace
122
+ ```
120
123
 
121
- If you used the `--use-yml` flag, the generator will create a YAML file at `config/asset_sync.yml`.
124
+ The Built-in Initializer also sets the AssetSync default for **existing_remote_files** to **keep**.
122
125
 
123
- defaults: &defaults
124
- fog_provider: "AWS"
125
- fog_directory: "rails-app-assets"
126
- aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID'] %>"
127
- aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
128
- # You may need to specify what region your storage bucket is in
129
- # fog_region: "eu-west-1"
130
- existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
131
- # To delete existing remote files.
132
- # existing_remote_files: delete
133
- # Automatically replace files with their equivalent gzip compressed version
134
- # gzip_compression: true
135
- # Fail silently. Useful for environments such as Heroku
136
- # fail_silently = true
126
+ ### Custom Rails Initializer (config/initializers/asset_sync.rb)
137
127
 
138
- development:
139
- <<: *defaults
128
+ If you want to enable some of the advanced configuration options you will want to create your own initializer.
140
129
 
141
- test:
142
- <<: *defaults
130
+ Run the included Rake task to generate a starting point.
143
131
 
144
- production:
145
- <<: *defaults
132
+ rails g asset_sync:install --provider=Rackspace
133
+ rails g asset_sync:install --provider=AWS
134
+
135
+ The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
146
136
 
147
- ### Environment Variables
137
+ ``` ruby
138
+ AssetSync.configure do |config|
139
+ config.fog_provider = 'AWS'
140
+ config.fog_directory = ENV['FOG_DIRECTORY']
141
+ config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
142
+ config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
143
+
144
+ # Don't delete files from the store
145
+ # config.existing_remote_files = "keep"
146
+ #
147
+ # Increase upload performance by configuring your region
148
+ # config.fog_region = 'eu-west-1'
149
+ #
150
+ # Automatically replace files with their equivalent gzip compressed version
151
+ # config.gzip_compression = true
152
+ #
153
+ # Use the Rails generated 'manifest.yml' file to produce the list of files to
154
+ # upload instead of searching the assets directory.
155
+ # config.manifest = true
156
+ #
157
+ # Fail silently. Useful for environments such as Heroku
158
+ # config.fail_silently = true
159
+ end
160
+ ```
148
161
 
149
- Add your Amazon S3 configuration details to **heroku**
162
+ ### YAML (config/asset_sync.yml)
150
163
 
151
- heroku config:add AWS_ACCESS_KEY_ID=xxxx
152
- heroku config:add AWS_SECRET_ACCESS_KEY=xxxx
153
- heroku config:add FOG_DIRECTORY=xxxx
164
+ Run the included Rake task to generate a starting point.
154
165
 
155
- Or add to a traditional unix system
166
+ rails g asset_sync:install --use-yml --provider=Rackspace
167
+ rails g asset_sync:install --use-yml --provider=AWS
156
168
 
157
- export AWS_ACCESS_KEY_ID=xxxx
158
- export AWS_SECRET_ACCESS_KEY=xxxx
159
- export FOG_DIRECTORY=xxxx
169
+ The generator will create a YAML file at `config/asset_sync.yml`.
170
+
171
+ ``` yaml
172
+ defaults: &defaults
173
+ fog_provider: "AWS"
174
+ fog_directory: "rails-app-assets"
175
+ aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID'] %>"
176
+ aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
177
+ # You may need to specify what region your storage bucket is in
178
+ # fog_region: "eu-west-1"
179
+ existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
180
+ # To delete existing remote files.
181
+ # existing_remote_files: delete
182
+ # Automatically replace files with their equivalent gzip compressed version
183
+ # gzip_compression: true
184
+ # Fail silently. Useful for environments such as Heroku
185
+ # fail_silently = true
186
+
187
+ development:
188
+ <<: *defaults
189
+
190
+ test:
191
+ <<: *defaults
192
+
193
+ production:
194
+ <<: *defaults
195
+ ```
160
196
 
161
197
  ### Available Configuration Options
162
198
 
163
- #### AssetSync
199
+ All AssetSync configuration can be modified directly using environment variables with the **Built-in initializer**. e.g.
200
+
201
+ ```ruby
202
+ AssetSync.config.fog_provider == ENV['FOG_PROVIDER']
203
+ ```
164
204
 
165
- * **existing_remote_files**: what to do with previously precompiled files, options are **keep** or **delete**
166
- * **gzip\_compression**: when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version.
167
- * **manifest**: when enabled, will use the `manifest.yml` generated by Rails to get the list of local files to upload. **experimental**
205
+ Simply **upcase** the ruby attribute names to get the equivalent environment variable to set. The only exception to that rule are the internal **AssetSync** config variables, they must be prepended with `ASSET_SYNC_*` e.g.
168
206
 
169
- #### Required (Fog)
207
+ ```ruby
208
+ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
209
+ ```
210
+
211
+ #### AssetSync (optional)
212
+
213
+ * **existing_remote_files**: (`'keep', 'delete'`) what to do with previously precompiled files. **default:** `'keep'`
214
+ * **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
215
+ * **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
+
217
+ #### Fog (Required)
170
218
  * **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files)
171
219
  * **fog\_directory**: your bucket name
172
220
 
173
- #### Optional
221
+ #### Fog (Optional)
174
222
 
175
223
  * **fog\_region**: the region your storage bucket is in e.g. *eu-west-1*
176
224
 
@@ -184,24 +232,35 @@ Or add to a traditional unix system
184
232
  * **rackspace\_username**: your Rackspace username
185
233
  * **rackspace\_api\_key**: your Rackspace API Key.
186
234
 
187
- #### Rackspace Optional
235
+ #### Rackspace (Optional)
188
236
 
189
237
  * **rackspace\_auth\_url**: Rackspace auth URL, for Rackspace London use: lon.auth.api.rackspacecloud.com
190
238
 
191
239
  ## Amazon S3 Multiple Region Support
192
240
 
193
- If you are using anything other than the US buckets with S3 then you'll want to set the **region**. For example with an EU bucket you could set the following with YAML.
241
+ If you are using anything other than the US buckets with S3 then you'll want to set the **region**. For example with an EU bucket you could set the following environment variable.
194
242
 
195
- production:
196
- # ...
197
- aws_region: 'eu-west-1'
243
+ ``` bash
244
+ heroku config:add FOG_REGION=eu-west-1
245
+ ```
198
246
 
199
- Or via the initializer
247
+ Or via a custom initializer
248
+
249
+ ``` ruby
250
+ AssetSync.configure do |config|
251
+ # ...
252
+ config.fog_region = 'eu-west-1'
253
+ end
254
+ ```
255
+
256
+ Or via YAML
257
+
258
+ ``` yaml
259
+ production:
260
+ # ...
261
+ aws_region: 'eu-west-1'
262
+ ```
200
263
 
201
- AssetSync.configure do |config|
202
- # ...
203
- config.fog_region = 'eu-west-1'
204
- end
205
264
 
206
265
  ## Automatic gzip compression
207
266
 
@@ -209,30 +268,43 @@ With the `gzip_compression` option enabled, when uploading your assets. If a fil
209
268
 
210
269
  If the compressed file is actually larger than the uncompressed file we will ignore this rule and upload the standard uncompressed version.
211
270
 
212
- ## Heroku
271
+ ## Fail Silently
272
+
273
+ With the `fail_silently` option enabled, when running `rake assets:precompile` AssetSync will never throw an error due to missing configuration variables.
274
+
275
+ With the new **user_env_compile** feature of Heroku (see above), this is no longer required or recommended. Yet was added for the following reasons:
213
276
 
214
- With Rails 3.1 on the Heroku cedar stack, the deployment process automatically runs `rake assets:precompile`. If you are using **ENV** variable style configuration. Due to the methods with which Heroku compile slugs, there will be an error raised by asset_sync as the environment is not available. This causes heroku to install the `rails31_enable_runtime_asset_compilation` plugin which is not necessary when using **asset_sync** and also massively slows down the first incoming requests to your app.
277
+ > With Rails 3.1 on the Heroku cedar stack, the deployment process automatically runs `rake assets:precompile`. If you are using **ENV** variable style configuration. Due to the methods with which Heroku compile slugs, there will be an error raised by asset\_sync as the environment is not available. This causes heroku to install the `rails31_enable_runtime_asset_compilation` plugin which is not necessary when using **asset_sync** and also massively slows down the first incoming requests to your app.
215
278
 
216
- To prevent this part of the deploy from failing (asset_sync raising a config error), but carry on as normal set `fail_silently` to true in your configuration and ensure to run `heroku run rake assets:precompile` after deploy.
279
+ > To prevent this part of the deploy from failing (asset_sync raising a config error), but carry on as normal set `fail_silently` to true in your configuration and ensure to run `heroku run rake assets:precompile` after deploy.
217
280
 
218
281
  ## Rake Task
219
282
 
220
- A rake task is included in asset\_sync to enhance the rails precompile task by automatically running after it:
283
+ A rake task is included within the **asset_sync** gem to enhance the rails precompile task by automatically running after it.
221
284
 
222
- # asset_sync/lib/tasks/asset_sync.rake
285
+ ``` ruby
286
+ # asset_sync/lib/tasks/asset_sync.rake
287
+ if Rake::Task.task_defined?("assets:precompile:nondigest")
288
+ Rake::Task["assets:precompile:nondigest"].enhance do
289
+ AssetSync.sync
290
+ end
291
+ else
223
292
  Rake::Task["assets:precompile"].enhance do
224
293
  AssetSync.sync
225
294
  end
295
+ end
296
+ ```
226
297
 
227
298
  ## Todo
228
299
 
229
300
  1. Add some before and after filters for deleting and uploading
230
301
  2. Support more cloud storage providers
231
302
  3. Better test coverage
303
+ 4. Add rake tasks to clean old assets from a bucket
232
304
 
233
305
  ## Credits
234
306
 
235
- Have borrowed ideas from:
307
+ Inspired by:
236
308
 
237
309
  - [https://github.com/moocode/asset_id](https://github.com/moocode/asset_id)
238
310
  - [https://gist.github.com/1053855](https://gist.github.com/1053855)
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-01-30"
9
+ s.date = "2012-03-07"
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"]
data/docs/heroku.md ADDED
@@ -0,0 +1,36 @@
1
+ The following issues are currently present in Heroku if you are not following the steps outlined in the main [README](http://github.com/rumblelabs/asset_sync)
2
+
3
+ ## KNOWN ISSUES (IMPORTANT)
4
+
5
+ We are currently trying to talk with Heroku to iron these out.
6
+
7
+ 1. Will not work on heroku on an application with a *RAILS_ENV* configured as anything other than production
8
+ 2. Will not work on heroku using ENV variables with the configuration as described below, you must hardcode all variables
9
+
10
+ ### 1. RAILS_ENV
11
+
12
+ When you see `rake assets:precompile` during deployment. Heroku is actually running something like
13
+
14
+ env RAILS_ENV=production DATABASE_URL=scheme://user:pass@127.0.0.1/dbname bundle exec rake assets:precompile 2>&1
15
+
16
+ This means the *RAILS_ENV* you have set via *heroku:config* is not used.
17
+
18
+ **Workaround:** you could have just one S3 bucket dedicated to assets and ensure to set keep the existing remote files
19
+
20
+ AssetSync.configure do |config|
21
+ ...
22
+ config.fog_directory = 'app-assets'
23
+ config.existing_remote_files = "keep"
24
+ end
25
+
26
+ ### 2. ENV varables not available
27
+
28
+ Currently when heroku runs `rake assets:precompile` during deployment. It does not load your Rails application's environment config. This means using any **ENV** variables you could normally depend on are not available. For now you can just run `heroku run rake assets:precompile` after deploy.
29
+
30
+ **Workaround:** you could just hardcode your AWS credentials in the initializer or yml
31
+
32
+ AssetSync.configure do |config|
33
+ config.aws_access_key_id = 'xxx'
34
+ config.aws_secret_access_key = 'xxx'
35
+ config.fog_directory = 'mybucket'
36
+ end
@@ -22,13 +22,19 @@ module AssetSync
22
22
 
23
23
  def sync
24
24
  if config.fail_silently?
25
- puts config.errors.full_messages.join(', ') unless config && config.valid?
25
+ self.log 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
+ private
33
+
34
+ def log(msg)
35
+ STDERR.puts msg
36
+ end
37
+
32
38
  end
33
39
 
34
40
  end
@@ -41,8 +41,9 @@ module AssetSync
41
41
  end
42
42
 
43
43
  def manifest_path
44
- default = File.join(Rails.root, 'public', assets_prefix, 'manifest.yml')
45
- Rails.application.config.assets.manifest || default
44
+ directory =
45
+ Rails.application.config.assets.manifest || default_manifest_directory
46
+ "#{directory}/manifest.yml"
46
47
  end
47
48
 
48
49
  def gzip?
@@ -70,7 +71,7 @@ module AssetSync
70
71
  end
71
72
 
72
73
  def yml
73
- y ||= YAML.load(ERB.new(IO.read(yml_path)).result)[Rails.env] rescue nil || {}
74
+ @yml ||= YAML.load(ERB.new(IO.read(yml_path)).result)[Rails.env] rescue nil || {}
74
75
  end
75
76
 
76
77
  def yml_path
@@ -133,5 +134,10 @@ module AssetSync
133
134
  return options
134
135
  end
135
136
 
137
+ private
138
+
139
+ def default_manifest_directory
140
+ File.join(Rails.root, 'public', assets_prefix)
141
+ end
136
142
  end
137
143
  end
@@ -21,7 +21,9 @@ 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
- config.existing_remote_files = "keep"
24
+ config.existing_remote_files = ENV['ASSET_SYNC_EXISTING_REMOTE_FILES'] || "keep"
25
+ config.gzip_compression = ENV['ASSET_SYNC_GZIP_COMPRESSION'] == 'true'
26
+ config.manifest = ENV['ASSET_SYNC_MANIFEST'] == 'true'
25
27
  end
26
28
  end
27
29
 
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.2.9"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,15 +1,13 @@
1
- # Rails 3.2 compatibility
2
- if Rails.application.config.assets.digest
1
+ if Rake::Task.task_defined?("assets:precompile:nondigest")
3
2
  Rake::Task["assets:precompile:nondigest"].enhance do
4
3
  AssetSync.sync
5
4
  end
6
- # Rails 3.1.x compatibility
7
5
  else
8
6
  Rake::Task["assets:precompile"].enhance do
9
7
  # rails 3.1.1 will clear out Rails.application.config if the env vars
10
8
  # RAILS_GROUP and RAILS_ENV are not defined. We need to reload the
11
9
  # assets environment in this case.
12
- Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
10
+ # Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
13
11
  AssetSync.sync
14
12
  end
15
13
  end
@@ -138,7 +138,7 @@ describe AssetSync do
138
138
  end
139
139
 
140
140
  it "config.manifest_path should default to public/assets.." do
141
- Rails.application.config.assets.manifest = "/var/assets/manifest.yml"
141
+ Rails.application.config.assets.manifest = "/var/assets"
142
142
  AssetSync.config.manifest_path.should == "/var/assets/manifest.yml"
143
143
  end
144
144
 
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,7 @@ shared_context "mock Rails" do
26
26
  Rails.application.stub :config => mock('config')
27
27
  Rails.application.config.stub :assets => ActiveSupport::OrderedOptions.new
28
28
  Rails.application.config.assets.prefix = '/assets'
29
+ AssetSync.stub!(:log)
29
30
  end
30
31
  end
31
32
 
metadata CHANGED
@@ -1,91 +1,89 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: asset_sync
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.9
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Simon Hamilton
9
9
  - David Rice
10
10
  - Phil McClure
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2012-01-30 00:00:00 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
14
+ date: 2012-03-07 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
18
17
  name: fog
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &70330270051360 !ruby/object:Gem::Requirement
21
19
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: "0"
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
26
24
  type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: activemodel
30
25
  prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: *70330270051360
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: &70330270050940 !ruby/object:Gem::Requirement
32
30
  none: false
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
37
35
  type: :runtime
38
- version_requirements: *id002
39
- - !ruby/object:Gem::Dependency
40
- name: rspec
41
36
  prerelease: false
42
- requirement: &id003 !ruby/object:Gem::Requirement
37
+ version_requirements: *70330270050940
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ requirement: &70330270050520 !ruby/object:Gem::Requirement
43
41
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
48
46
  type: :development
49
- version_requirements: *id003
50
- - !ruby/object:Gem::Dependency
51
- name: bundler
52
47
  prerelease: false
53
- requirement: &id004 !ruby/object:Gem::Requirement
48
+ version_requirements: *70330270050520
49
+ - !ruby/object:Gem::Dependency
50
+ name: bundler
51
+ requirement: &70330270050100 !ruby/object:Gem::Requirement
54
52
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
59
57
  type: :development
60
- version_requirements: *id004
61
- - !ruby/object:Gem::Dependency
62
- name: jeweler
63
58
  prerelease: false
64
- requirement: &id005 !ruby/object:Gem::Requirement
59
+ version_requirements: *70330270050100
60
+ - !ruby/object:Gem::Dependency
61
+ name: jeweler
62
+ requirement: &70330270049680 !ruby/object:Gem::Requirement
65
63
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
70
68
  type: :development
71
- version_requirements: *id005
72
- description: After you run assets:precompile your compiled assets will be synchronised with your S3 bucket.
73
- email:
69
+ prerelease: false
70
+ version_requirements: *70330270049680
71
+ description: After you run assets:precompile your compiled assets will be synchronised
72
+ with your S3 bucket.
73
+ email:
74
74
  - shamilton@rumblelabs.com
75
75
  - me@davidjrice.co.uk
76
76
  - pmcclure@rumblelabs.com
77
77
  executables: []
78
-
79
78
  extensions: []
80
-
81
79
  extra_rdoc_files: []
82
-
83
- files:
80
+ files:
84
81
  - .gitignore
85
82
  - Gemfile
86
83
  - README.md
87
84
  - Rakefile
88
85
  - asset_sync.gemspec
86
+ - docs/heroku.md
89
87
  - lib/asset_sync.rb
90
88
  - lib/asset_sync/asset_sync.rb
91
89
  - lib/asset_sync/config.rb
@@ -104,34 +102,33 @@ files:
104
102
  - spec/spec_helper.rb
105
103
  homepage: https://github.com/rumblelabs/asset_sync
106
104
  licenses: []
107
-
108
105
  post_install_message:
109
106
  rdoc_options: []
110
-
111
- require_paths:
107
+ require_paths:
112
108
  - lib
113
- required_ruby_version: !ruby/object:Gem::Requirement
109
+ required_ruby_version: !ruby/object:Gem::Requirement
114
110
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
116
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: "0"
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
125
121
  requirements: []
126
-
127
122
  rubyforge_project: asset_sync
128
123
  rubygems_version: 1.8.10
129
124
  signing_key:
130
125
  specification_version: 3
131
- summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and Rackspace Cloudfiles
132
- test_files:
126
+ summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and
127
+ Rackspace Cloudfiles
128
+ test_files:
133
129
  - spec/asset_sync_spec.rb
134
130
  - spec/aws_with_yml/config/asset_sync.yml
135
131
  - spec/rackspace_spec.rb
136
132
  - spec/rackspace_with_yml/config/asset_sync.yml
137
133
  - spec/spec_helper.rb
134
+ has_rdoc: