asset_sync 0.2.10 → 0.2.11

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,55 +9,33 @@ 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
24
-
25
- env RAILS_ENV=production DATABASE_URL=scheme://user:pass@127.0.0.1/dbname bundle exec rake assets:precompile 2>&1
26
-
27
- This means the *RAILS_ENV* you have set via *heroku:config* is not used.
28
-
29
- **Workaround:** you could have just one S3 bucket dedicated to assets and ensure to set keep the existing remote files
30
-
31
- AssetSync.configure do |config|
32
- ...
33
- config.fog_directory = 'app-assets'
34
- config.existing_remote_files = "keep"
35
- end
36
-
37
- ### 2. ENV varables not available
38
-
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.
40
-
41
- **Workaround:** you could just hardcode your AWS credentials in the initializer or yml
42
-
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
23
+ Hopefully this will make it's way into the platform as standard.
48
24
 
49
25
  ## Installation
50
26
 
51
27
  Add the gem to your Gemfile
52
28
 
53
- gem "asset_sync"
29
+ ``` ruby
30
+ gem "asset_sync"
31
+ ```
54
32
 
55
33
  > 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)
56
34
 
57
35
  Generate the rake task and config file
58
36
 
59
37
  rails g asset_sync:install
60
-
38
+
61
39
  If you would like to use a YAML file for configuration instead of the default (Rails Initializer) then
62
40
 
63
41
  rails g asset_sync:install --use-yml
@@ -72,10 +50,12 @@ The default *provider* is `AWS` but you can pick which one you need.
72
50
  Configure __config/environments/production.rb__ to use Amazon
73
51
  S3 as the asset host and ensure precompiling is enabled.
74
52
 
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
53
+ ``` ruby
54
+ # config/environments/production.rb
55
+ config.action_controller.asset_host = Proc.new do |source, request|
56
+ request.ssl? ? "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com" : "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
57
+ end
58
+ ```
79
59
 
80
60
  We support two methods of configuration.
81
61
 
@@ -92,57 +72,61 @@ The recommend way to configure **asset_sync** is by using environment variables
92
72
 
93
73
  The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
94
74
 
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
75
+ ``` ruby
76
+ AssetSync.configure do |config|
77
+ config.fog_provider = 'AWS'
78
+ config.fog_directory = ENV['FOG_DIRECTORY']
79
+ config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
80
+ config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
81
+
82
+ # Don't delete files from the store
83
+ # config.existing_remote_files = "keep"
84
+ #
85
+ # Increase upload performance by configuring your region
86
+ # config.fog_region = 'eu-west-1'
87
+ #
88
+ # Automatically replace files with their equivalent gzip compressed version
89
+ # config.gzip_compression = true
90
+ #
91
+ # Use the Rails generated 'manifest.yml' file to produce the list of files to
92
+ # upload instead of searching the assets directory.
93
+ # config.manifest = true
94
+ #
95
+ # Fail silently. Useful for environments such as Heroku
96
+ # config.fail_silently = true
97
+ end
98
+ ```
117
99
 
118
100
 
119
101
  ### YAML (config/asset_sync.yml)
120
102
 
121
103
  If you used the `--use-yml` flag, the generator will create a YAML file at `config/asset_sync.yml`.
122
104
 
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
137
-
138
- development:
139
- <<: *defaults
140
-
141
- test:
142
- <<: *defaults
143
-
144
- production:
145
- <<: *defaults
105
+ ``` yaml
106
+ defaults: &defaults
107
+ fog_provider: "AWS"
108
+ fog_directory: "rails-app-assets"
109
+ aws_access_key_id: "<%= ENV['AWS_ACCESS_KEY_ID'] %>"
110
+ aws_secret_access_key: "<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
111
+ # You may need to specify what region your storage bucket is in
112
+ # fog_region: "eu-west-1"
113
+ existing_remote_files: keep # Existing pre-compiled assets on S3 will be kept
114
+ # To delete existing remote files.
115
+ # existing_remote_files: delete
116
+ # Automatically replace files with their equivalent gzip compressed version
117
+ # gzip_compression: true
118
+ # Fail silently. Useful for environments such as Heroku
119
+ # fail_silently = true
120
+
121
+ development:
122
+ <<: *defaults
123
+
124
+ test:
125
+ <<: *defaults
126
+
127
+ production:
128
+ <<: *defaults
129
+ ```
146
130
 
147
131
  ### Environment Variables
148
132
 
@@ -154,9 +138,11 @@ Add your Amazon S3 configuration details to **heroku**
154
138
 
155
139
  Or add to a traditional unix system
156
140
 
157
- export AWS_ACCESS_KEY_ID=xxxx
158
- export AWS_SECRET_ACCESS_KEY=xxxx
159
- export FOG_DIRECTORY=xxxx
141
+ ``` bash
142
+ export AWS_ACCESS_KEY_ID=xxxx
143
+ export AWS_SECRET_ACCESS_KEY=xxxx
144
+ export FOG_DIRECTORY=xxxx
145
+ ```
160
146
 
161
147
  ### Available Configuration Options
162
148
 
@@ -192,16 +178,20 @@ Or add to a traditional unix system
192
178
 
193
179
  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.
194
180
 
195
- production:
196
- # ...
197
- aws_region: 'eu-west-1'
181
+ ``` yaml
182
+ production:
183
+ # ...
184
+ aws_region: 'eu-west-1'
185
+ ```
198
186
 
199
187
  Or via the initializer
200
188
 
201
- AssetSync.configure do |config|
202
- # ...
203
- config.fog_region = 'eu-west-1'
204
- end
189
+ ``` ruby
190
+ AssetSync.configure do |config|
191
+ # ...
192
+ config.fog_region = 'eu-west-1'
193
+ end
194
+ ```
205
195
 
206
196
  ## Automatic gzip compression
207
197
 
@@ -219,10 +209,12 @@ To prevent this part of the deploy from failing (asset_sync raising a config err
219
209
 
220
210
  A rake task is included in asset\_sync to enhance the rails precompile task by automatically running after it:
221
211
 
222
- # asset_sync/lib/tasks/asset_sync.rake
223
- Rake::Task["assets:precompile"].enhance do
224
- AssetSync.sync
225
- end
212
+ ``` ruby
213
+ # asset_sync/lib/tasks/asset_sync.rake
214
+ Rake::Task["assets:precompile"].enhance do
215
+ AssetSync.sync
216
+ end
217
+ ```
226
218
 
227
219
  ## Todo
228
220
 
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-02-16"
9
+ s.date = "2012-03-04"
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
@@ -71,7 +71,7 @@ module AssetSync
71
71
  end
72
72
 
73
73
  def yml
74
- 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 || {}
75
75
  end
76
76
 
77
77
  def yml_path
@@ -1,3 +1,3 @@
1
1
  module AssetSync
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.11"
3
3
  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.2.10
4
+ version: 0.2.11
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-02-16 00:00:00.000000000Z
14
+ date: 2012-03-04 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog
18
- requirement: &70301574351660 !ruby/object:Gem::Requirement
18
+ requirement: &70259782223240 !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: *70301574351660
26
+ version_requirements: *70259782223240
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
- requirement: &70301574350960 !ruby/object:Gem::Requirement
29
+ requirement: &70259782222820 !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: *70301574350960
37
+ version_requirements: *70259782222820
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70301574349740 !ruby/object:Gem::Requirement
40
+ requirement: &70259782222400 !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: *70301574349740
48
+ version_requirements: *70259782222400
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: bundler
51
- requirement: &70301574348040 !ruby/object:Gem::Requirement
51
+ requirement: &70259782221980 !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: *70301574348040
59
+ version_requirements: *70259782221980
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: jeweler
62
- requirement: &70301574346200 !ruby/object:Gem::Requirement
62
+ requirement: &70259782221560 !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: *70301574346200
70
+ version_requirements: *70259782221560
71
71
  description: After you run assets:precompile your compiled assets will be synchronised
72
72
  with your S3 bucket.
73
73
  email:
@@ -83,6 +83,7 @@ files:
83
83
  - README.md
84
84
  - Rakefile
85
85
  - asset_sync.gemspec
86
+ - docs/heroku.md
86
87
  - lib/asset_sync.rb
87
88
  - lib/asset_sync/asset_sync.rb
88
89
  - lib/asset_sync/config.rb