asset_hat 0.2.1 → 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.
Files changed (46) hide show
  1. data/HISTORY +38 -19
  2. data/README.rdoc +99 -41
  3. data/Rakefile +17 -10
  4. data/VERSION.yml +3 -3
  5. data/app/helpers/asset_hat_helper.rb +40 -20
  6. data/asset_hat.gemspec +105 -101
  7. data/doc/classes/AssetHat.html +173 -59
  8. data/doc/classes/AssetHat/CSS.html +35 -26
  9. data/doc/classes/AssetHat/CSS/Engines.html +13 -12
  10. data/doc/classes/AssetHat/JS.html +11 -11
  11. data/doc/classes/AssetHat/JS/Engines.html +10 -10
  12. data/doc/classes/AssetHat/JS/Vendors.html +9 -5
  13. data/doc/classes/AssetHatHelper.html +18 -14
  14. data/doc/created.rid +1 -1
  15. data/doc/files/HISTORY.html +66 -24
  16. data/doc/files/LICENSE.html +1 -1
  17. data/doc/files/README_rdoc.html +112 -37
  18. data/doc/files/app/helpers/asset_hat_helper_rb.html +1 -1
  19. data/doc/files/lib/asset_hat/capistrano_rb.html +1 -1
  20. data/doc/files/lib/asset_hat/css_rb.html +1 -1
  21. data/doc/files/lib/asset_hat/js/vendors_rb.html +1 -1
  22. data/doc/files/lib/asset_hat/js_rb.html +1 -1
  23. data/doc/files/lib/asset_hat/tasks/css_rb.html +1 -1
  24. data/doc/files/lib/asset_hat/tasks/js_rb.html +1 -1
  25. data/doc/files/lib/asset_hat/tasks_rb.html +1 -1
  26. data/doc/files/lib/asset_hat/vcs_rb.html +1 -1
  27. data/doc/files/lib/asset_hat/version_rb.html +1 -1
  28. data/doc/files/lib/asset_hat_rb.html +1 -1
  29. data/doc/fr_method_index.html +54 -46
  30. data/lib/asset_hat.rb +100 -16
  31. data/lib/asset_hat/capistrano.rb +4 -3
  32. data/lib/asset_hat/css.rb +69 -20
  33. data/lib/asset_hat/js.rb +2 -2
  34. data/lib/asset_hat/js/vendors.rb +14 -10
  35. data/lib/asset_hat/tasks.rb +22 -3
  36. data/lib/asset_hat/tasks/css.rb +118 -74
  37. data/lib/asset_hat/tasks/js.rb +79 -35
  38. data/lib/asset_hat/vcs.rb +19 -0
  39. data/public/stylesheets/bundles/ssl/css-bundle-1.min.css +3 -0
  40. data/public/stylesheets/bundles/ssl/css-bundle-2.min.css +3 -0
  41. data/public/stylesheets/bundles/ssl/css-bundle-3.min.css +3 -0
  42. data/rails/init.rb +1 -16
  43. data/test/asset_hat_helper_test.rb +172 -28
  44. data/test/asset_hat_test.rb +167 -25
  45. metadata +54 -21
  46. data/.gitignore +0 -2
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Mon Nov 15 10:51:11 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Mon Nov 15 10:51:11 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Mon Nov 15 10:51:11 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Mon Nov 15 10:51:11 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Mon Nov 15 10:51:12 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Wed Jul 21 11:50:30 -0400 2010</span>
34
+ <span class='datetime'>Tue Nov 16 18:40:37 -0500 2010</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -4331,30 +4331,34 @@
4331
4331
 
4332
4332
  Element.addMethods();
4333
4333
  var search_index = [
4334
- { method: 'add_asset_commit_ids', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000014"><span class="method_name">add_asset_commit_ids</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4335
- { method: 'add_asset_hosts', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000015"><span class="method_name">add_asset_hosts</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4336
- { method: 'asset_exists?', module: 'assethat', html: '<a href="classes/AssetHat.html#M000006"><span class="method_name">asset_exists?</span> <span class="module_name">(AssetHat)</span></a>' },
4337
- { method: 'assets_dir', module: 'assethat', html: '<a href="classes/AssetHat.html#M000005"><span class="method_name">assets_dir</span> <span class="module_name">(AssetHat)</span></a>' },
4338
- { method: 'bundle_filenames', module: 'assethat', html: '<a href="classes/AssetHat.html#M000009"><span class="method_name">bundle_filenames</span> <span class="module_name">(AssetHat)</span></a>' },
4339
- { method: 'bundle_filepaths', module: 'assethat', html: '<a href="classes/AssetHat.html#M000010"><span class="method_name">bundle_filepaths</span> <span class="module_name">(AssetHat)</span></a>' },
4340
- { method: 'cache?', module: 'assethat', html: '<a href="classes/AssetHat.html#M000007"><span class="method_name">cache?</span> <span class="module_name">(AssetHat)</span></a>' },
4341
- { method: 'clear_html_cache', module: 'assethat', html: '<a href="classes/AssetHat.html#M000011"><span class="method_name">clear_html_cache</span> <span class="module_name">(AssetHat)</span></a>' },
4342
- { method: 'config', module: 'assethat', html: '<a href="classes/AssetHat.html#M000004"><span class="method_name">config</span> <span class="module_name">(AssetHat)</span></a>' },
4343
- { method: 'cssmin', module: 'assethat::css::engines', html: '<a href="classes/AssetHat/CSS/Engines.html#M000017"><span class="method_name">cssmin</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a>' },
4344
- { method: 'include_css', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000023"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a>' },
4345
- { method: 'include_js', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000024"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a>' },
4346
- { method: 'jsmin', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000022"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
4347
- { method: 'last_bundle_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#M000003"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a>' },
4334
+ { method: 'add_asset_commit_ids', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000018"><span class="method_name">add_asset_commit_ids</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4335
+ { method: 'add_asset_hosts', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000019"><span class="method_name">add_asset_hosts</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4336
+ { method: 'asset_exists?', module: 'assethat', html: '<a href="classes/AssetHat.html#M000008"><span class="method_name">asset_exists?</span> <span class="module_name">(AssetHat)</span></a>' },
4337
+ { method: 'assets_dir', module: 'assethat', html: '<a href="classes/AssetHat.html#M000006"><span class="method_name">assets_dir</span> <span class="module_name">(AssetHat)</span></a>' },
4338
+ { method: 'bundle_filenames', module: 'assethat', html: '<a href="classes/AssetHat.html#M000011"><span class="method_name">bundle_filenames</span> <span class="module_name">(AssetHat)</span></a>' },
4339
+ { method: 'bundle_filepaths', module: 'assethat', html: '<a href="classes/AssetHat.html#M000012"><span class="method_name">bundle_filepaths</span> <span class="module_name">(AssetHat)</span></a>' },
4340
+ { method: 'bundles_dir', module: 'assethat', html: '<a href="classes/AssetHat.html#M000007"><span class="method_name">bundles_dir</span> <span class="module_name">(AssetHat)</span></a>' },
4341
+ { method: 'cache?', module: 'assethat', html: '<a href="classes/AssetHat.html#M000009"><span class="method_name">cache?</span> <span class="module_name">(AssetHat)</span></a>' },
4342
+ { method: 'cache_last_commit_ids', module: 'assethat', html: '<a href="classes/AssetHat.html#M000003"><span class="method_name">cache_last_commit_ids</span> <span class="module_name">(AssetHat)</span></a>' },
4343
+ { method: 'clear_html_cache', module: 'assethat', html: '<a href="classes/AssetHat.html#M000015"><span class="method_name">clear_html_cache</span> <span class="module_name">(AssetHat)</span></a>' },
4344
+ { method: 'compute_asset_host', module: 'assethat', html: '<a href="classes/AssetHat.html#M000013"><span class="method_name">compute_asset_host</span> <span class="module_name">(AssetHat)</span></a>' },
4345
+ { method: 'config', module: 'assethat', html: '<a href="classes/AssetHat.html#M000005"><span class="method_name">config</span> <span class="module_name">(AssetHat)</span></a>' },
4346
+ { method: 'cssmin', module: 'assethat::css::engines', html: '<a href="classes/AssetHat/CSS/Engines.html#M000021"><span class="method_name">cssmin</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a>' },
4347
+ { method: 'include_css', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000027"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a>' },
4348
+ { method: 'include_js', module: 'assethathelper', html: '<a href="classes/AssetHatHelper.html#M000028"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a>' },
4349
+ { method: 'jsmin', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000026"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
4350
+ { method: 'last_bundle_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#M000002"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a>' },
4348
4351
  { method: 'last_commit_id', module: 'assethat', html: '<a href="classes/AssetHat.html#M000001"><span class="method_name">last_commit_id</span> <span class="module_name">(AssetHat)</span></a>' },
4349
- { method: 'min_filepath', module: 'assethat', html: '<a href="classes/AssetHat.html#M000008"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a>' },
4350
- { method: 'min_filepath', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000012"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4351
- { method: 'min_filepath', module: 'assethat::js', html: '<a href="classes/AssetHat/JS.html#M000018"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::JS)</span></a>' },
4352
- { method: 'minify', module: 'assethat::js', html: '<a href="classes/AssetHat/JS.html#M000019"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a>' },
4353
- { method: 'minify', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000013"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4354
- { method: 'source_for', module: 'assethat::js::vendors', html: '<a href="classes/AssetHat/JS/Vendors.html#M000020"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a>' },
4355
- { method: 'version', module: 'assethat', html: '<a href="classes/AssetHat.html#M000002"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a>' },
4356
- { method: 'weak', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000021"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
4357
- { method: 'weak', module: 'assethat::css::engines', html: '<a href="classes/AssetHat/CSS/Engines.html#M000016"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a>' },
4352
+ { method: 'min_filepath', module: 'assethat::js', html: '<a href="classes/AssetHat/JS.html#M000022"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::JS)</span></a>' },
4353
+ { method: 'min_filepath', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000016"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4354
+ { method: 'min_filepath', module: 'assethat', html: '<a href="classes/AssetHat.html#M000010"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a>' },
4355
+ { method: 'minify', module: 'assethat::css', html: '<a href="classes/AssetHat/CSS.html#M000017"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a>' },
4356
+ { method: 'minify', module: 'assethat::js', html: '<a href="classes/AssetHat/JS.html#M000023"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a>' },
4357
+ { method: 'source_for', module: 'assethat::js::vendors', html: '<a href="classes/AssetHat/JS/Vendors.html#M000024"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a>' },
4358
+ { method: 'ssl_asset_host_differs?', module: 'assethat', html: '<a href="classes/AssetHat.html#M000014"><span class="method_name">ssl_asset_host_differs?</span> <span class="module_name">(AssetHat)</span></a>' },
4359
+ { method: 'version', module: 'assethat', html: '<a href="classes/AssetHat.html#M000004"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a>' },
4360
+ { method: 'weak', module: 'assethat::js::engines', html: '<a href="classes/AssetHat/JS/Engines.html#M000025"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a>' },
4361
+ { method: 'weak', module: 'assethat::css::engines', html: '<a href="classes/AssetHat/CSS/Engines.html#M000020"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a>' },
4358
4362
  ]
4359
4363
  $(document).observe('dom:loaded', function() {
4360
4364
  // Setup search-during-typing.
@@ -4425,30 +4429,34 @@
4425
4429
  </form>
4426
4430
  <ol class='methods' id='search-results' style='display: none'></ol>
4427
4431
  <ol class='methods' id='index-entries'>
4428
- <li><a href="classes/AssetHat/CSS.html#M000014"><span class="method_name">add_asset_commit_ids</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4429
- <li><a href="classes/AssetHat/CSS.html#M000015"><span class="method_name">add_asset_hosts</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4430
- <li><a href="classes/AssetHat.html#M000006"><span class="method_name">asset_exists?</span> <span class="module_name">(AssetHat)</span></a></li>
4431
- <li><a href="classes/AssetHat.html#M000005"><span class="method_name">assets_dir</span> <span class="module_name">(AssetHat)</span></a></li>
4432
- <li><a href="classes/AssetHat.html#M000009"><span class="method_name">bundle_filenames</span> <span class="module_name">(AssetHat)</span></a></li>
4433
- <li><a href="classes/AssetHat.html#M000010"><span class="method_name">bundle_filepaths</span> <span class="module_name">(AssetHat)</span></a></li>
4434
- <li><a href="classes/AssetHat.html#M000007"><span class="method_name">cache?</span> <span class="module_name">(AssetHat)</span></a></li>
4435
- <li><a href="classes/AssetHat.html#M000011"><span class="method_name">clear_html_cache</span> <span class="module_name">(AssetHat)</span></a></li>
4436
- <li><a href="classes/AssetHat.html#M000004"><span class="method_name">config</span> <span class="module_name">(AssetHat)</span></a></li>
4437
- <li><a href="classes/AssetHat/CSS/Engines.html#M000017"><span class="method_name">cssmin</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a></li>
4438
- <li><a href="classes/AssetHatHelper.html#M000023"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a></li>
4439
- <li><a href="classes/AssetHatHelper.html#M000024"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a></li>
4440
- <li><a href="classes/AssetHat/JS/Engines.html#M000022"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
4441
- <li><a href="classes/AssetHat.html#M000003"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a></li>
4432
+ <li><a href="classes/AssetHat/CSS.html#M000018"><span class="method_name">add_asset_commit_ids</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4433
+ <li><a href="classes/AssetHat/CSS.html#M000019"><span class="method_name">add_asset_hosts</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4434
+ <li><a href="classes/AssetHat.html#M000008"><span class="method_name">asset_exists?</span> <span class="module_name">(AssetHat)</span></a></li>
4435
+ <li><a href="classes/AssetHat.html#M000006"><span class="method_name">assets_dir</span> <span class="module_name">(AssetHat)</span></a></li>
4436
+ <li><a href="classes/AssetHat.html#M000011"><span class="method_name">bundle_filenames</span> <span class="module_name">(AssetHat)</span></a></li>
4437
+ <li><a href="classes/AssetHat.html#M000012"><span class="method_name">bundle_filepaths</span> <span class="module_name">(AssetHat)</span></a></li>
4438
+ <li><a href="classes/AssetHat.html#M000007"><span class="method_name">bundles_dir</span> <span class="module_name">(AssetHat)</span></a></li>
4439
+ <li><a href="classes/AssetHat.html#M000009"><span class="method_name">cache?</span> <span class="module_name">(AssetHat)</span></a></li>
4440
+ <li><a href="classes/AssetHat.html#M000003"><span class="method_name">cache_last_commit_ids</span> <span class="module_name">(AssetHat)</span></a></li>
4441
+ <li><a href="classes/AssetHat.html#M000015"><span class="method_name">clear_html_cache</span> <span class="module_name">(AssetHat)</span></a></li>
4442
+ <li><a href="classes/AssetHat.html#M000013"><span class="method_name">compute_asset_host</span> <span class="module_name">(AssetHat)</span></a></li>
4443
+ <li><a href="classes/AssetHat.html#M000005"><span class="method_name">config</span> <span class="module_name">(AssetHat)</span></a></li>
4444
+ <li><a href="classes/AssetHat/CSS/Engines.html#M000021"><span class="method_name">cssmin</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a></li>
4445
+ <li><a href="classes/AssetHatHelper.html#M000027"><span class="method_name">include_css</span> <span class="module_name">(AssetHatHelper)</span></a></li>
4446
+ <li><a href="classes/AssetHatHelper.html#M000028"><span class="method_name">include_js</span> <span class="module_name">(AssetHatHelper)</span></a></li>
4447
+ <li><a href="classes/AssetHat/JS/Engines.html#M000026"><span class="method_name">jsmin</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
4448
+ <li><a href="classes/AssetHat.html#M000002"><span class="method_name">last_bundle_commit_id</span> <span class="module_name">(AssetHat)</span></a></li>
4442
4449
  <li><a href="classes/AssetHat.html#M000001"><span class="method_name">last_commit_id</span> <span class="module_name">(AssetHat)</span></a></li>
4443
- <li><a href="classes/AssetHat.html#M000008"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a></li>
4444
- <li><a href="classes/AssetHat/CSS.html#M000012"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4445
- <li><a href="classes/AssetHat/JS.html#M000018"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::JS)</span></a></li>
4446
- <li><a href="classes/AssetHat/JS.html#M000019"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a></li>
4447
- <li><a href="classes/AssetHat/CSS.html#M000013"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4448
- <li><a href="classes/AssetHat/JS/Vendors.html#M000020"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a></li>
4449
- <li><a href="classes/AssetHat.html#M000002"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a></li>
4450
- <li><a href="classes/AssetHat/JS/Engines.html#M000021"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
4451
- <li><a href="classes/AssetHat/CSS/Engines.html#M000016"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a></li>
4450
+ <li><a href="classes/AssetHat/JS.html#M000022"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::JS)</span></a></li>
4451
+ <li><a href="classes/AssetHat/CSS.html#M000016"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4452
+ <li><a href="classes/AssetHat.html#M000010"><span class="method_name">min_filepath</span> <span class="module_name">(AssetHat)</span></a></li>
4453
+ <li><a href="classes/AssetHat/CSS.html#M000017"><span class="method_name">minify</span> <span class="module_name">(AssetHat::CSS)</span></a></li>
4454
+ <li><a href="classes/AssetHat/JS.html#M000023"><span class="method_name">minify</span> <span class="module_name">(AssetHat::JS)</span></a></li>
4455
+ <li><a href="classes/AssetHat/JS/Vendors.html#M000024"><span class="method_name">source_for</span> <span class="module_name">(AssetHat::JS::Vendors)</span></a></li>
4456
+ <li><a href="classes/AssetHat.html#M000014"><span class="method_name">ssl_asset_host_differs?</span> <span class="module_name">(AssetHat)</span></a></li>
4457
+ <li><a href="classes/AssetHat.html#M000004"><span class="method_name">version</span> <span class="module_name">(AssetHat)</span></a></li>
4458
+ <li><a href="classes/AssetHat/JS/Engines.html#M000025"><span class="method_name">weak</span> <span class="module_name">(AssetHat::JS::Engines)</span></a></li>
4459
+ <li><a href="classes/AssetHat/CSS/Engines.html#M000020"><span class="method_name">weak</span> <span class="module_name">(AssetHat::CSS::Engines)</span></a></li>
4452
4460
  </ol>
4453
4461
  </div>
4454
4462
  </body>
data/lib/asset_hat.rb CHANGED
@@ -17,7 +17,7 @@ end
17
17
  # just the current host.
18
18
  # * Add an image's last Git[http://git-scm.com/] commit ID to its CSS URLs to
19
19
  # <strong>bust browser caches</strong> (e.g.,
20
- # <code>/images/foo.png?ab12cd34e</code>).
20
+ # <code>/images/foo.png?ab12cd3</code>).
21
21
  #
22
22
  # After setup, you can use these in your layouts and views:
23
23
  #
@@ -46,10 +46,10 @@ module AssetHat
46
46
  ASSETS_DIR = defined?(Rails.public_path) ? Rails.public_path : 'public'
47
47
 
48
48
  # Directory in which all stylesheets are kept, e.g., 'public/stylesheets/'.
49
- STYLESHEETS_DIR = "#{ASSETS_DIR}/stylesheets"
49
+ STYLESHEETS_DIR = File.join(ASSETS_DIR, 'stylesheets')
50
50
 
51
51
  # Directory in which all JavaScripts are kept, e.g., 'public/javascripts/'.
52
- JAVASCRIPTS_DIR = "#{ASSETS_DIR}/javascripts"
52
+ JAVASCRIPTS_DIR = File.join(ASSETS_DIR, 'javascripts')
53
53
 
54
54
  # Relative path for the config file.
55
55
  RELATIVE_CONFIG_FILEPATH = File.join('config', 'assets.yml')
@@ -64,31 +64,66 @@ module AssetHat
64
64
  # Nested-hash version of <code>config/assets.yml</code>.
65
65
  def self.config
66
66
  if !cache? || @config.blank?
67
- @config = YAML.load(File.open(CONFIG_FILEPATH, 'r'))
67
+ @config = YAML.load(ERB.new(File.read(CONFIG_FILEPATH)).result)
68
68
  end
69
69
  @config
70
70
  end
71
71
 
72
- # Argument: <code>:css</code> or <code>:js</code>
72
+ # Returns the relative path to the directory where the original CSS or JS
73
+ # files are stored.
73
74
  #
74
- # Returns the path to the directory where CSS or JS files are stored.
75
+ # <code>type</code> argument: <code>:css</code> or <code>:js</code>
75
76
  def self.assets_dir(type)
76
- case type.to_sym
77
+ type = type.to_sym
78
+
79
+ unless TYPES.include?(type)
80
+ raise "Unknown type \"#{type}\"; should be one of: #{TYPES.join(', ')}."
81
+ return
82
+ end
83
+
84
+ case type
77
85
  when :css ; STYLESHEETS_DIR
78
86
  when :js ; JAVASCRIPTS_DIR
79
87
  else nil
80
88
  end
81
89
  end
82
90
 
91
+ # Returns the relative path to the directory where CSS or JS bundles are
92
+ # stored.
93
+ #
94
+ # Usage:
95
+ #
96
+ # AssetHat.bundles_dir
97
+ # # => 'bundles'
98
+ # AssetHat.bundles_dir(:ssl => true)
99
+ # # => 'bundles/ssl'
100
+ # AssetHat.bundles_dir(:css)
101
+ # # => 'public/stylesheets/bundles'
102
+ # AssetHat.bundles_dir(:js, :ssl => true)
103
+ # # => 'public/javascripts/bundles/ssl
104
+ #
105
+ # Options:
106
+ #
107
+ # [ssl] Set this to <code>true</code> if the stylesheet references images
108
+ # via SSL. Defaults to <code>false</code>.
109
+ def self.bundles_dir(*args)
110
+ options = args.extract_options!
111
+ options.symbolize_keys!.reverse_merge!(:ssl => false)
112
+ type = args.first
113
+
114
+ dir = type.present? ? File.join(assets_dir(type), 'bundles') : 'bundles'
115
+ dir = File.join(dir, 'ssl') if options[:ssl]
116
+ dir
117
+ end
118
+
83
119
  # Returns true if the specified asset exists in the file system:
84
120
  #
85
- # AssetHat.asset_exists?('application', :css)
86
- # # => true if /public/stylesheets/application.css exists
87
- # AssetHat.asset_exists?('some-plugin', :js)
88
- # # => true if /public/javascripts/some-plugin.js exists
121
+ # AssetHat.asset_exists?('application.css', :css)
122
+ # # => true if public/stylesheets/application.css exists
123
+ # AssetHat.asset_exists?('some-plugin.js', :js)
124
+ # # => true if public/javascripts/some-plugin.js exists
89
125
  #
90
- # See also <code>AssetHat::STYLESHEETS_DIR</code> and
91
- # <code>AssetHat::JAVASCRIPTS_DIR</code>.
126
+ # See also <code>AssetHat.assets_dir</code>.
92
127
  def self.asset_exists?(filename, type)
93
128
  # Process arguments
94
129
  type = type.to_sym
@@ -97,9 +132,9 @@ module AssetHat
97
132
  return
98
133
  end
99
134
 
100
- @asset_exists ||= TYPES.inject({}) do |hsh, known_type|
101
- hsh.merge!(known_type => {})
102
- end
135
+ # Default to `{:css => {}, :js => {}}`
136
+ @asset_exists ||= TYPES.inject({}) { |hsh, t| hsh.merge(t => {}) }
137
+
103
138
  if @asset_exists[type][filename].nil?
104
139
  @asset_exists[type][filename] =
105
140
  File.exist?(File.join(self.assets_dir(type), filename))
@@ -162,6 +197,55 @@ module AssetHat
162
197
  filenames.map { |fn| File.join(dir, "#{fn}.#{type}") } : nil
163
198
  end
164
199
 
200
+ # Reads <code>ActionController::Base.asset_host</code>, which can be a
201
+ # String or Proc, and returns a String. Should behave just like Rails
202
+ # 2.3.x's private `compute_asset_host` method, but with a simulated request.
203
+ #
204
+ # Example environment config for CDN support via SSL:
205
+ #
206
+ # # In config/environments/production.rb:
207
+ # config.action_controller.asset_host = Proc.new do |source, request|
208
+ # "#{request.protocol}cdn#{source.hash % 4}.example.com"
209
+ # # => 'http://cdn0.example.com', 'https://cdn1.example.com', etc.
210
+ # end
211
+ #
212
+ # If your CDN doesn't have SSL support, you can instead revert SSL pages to
213
+ # serving assets from your web server:
214
+ #
215
+ # config.action_controller.asset_host = Proc.new do |source, request|
216
+ # request.ssl? ? nil : "http://cdn#{source.hash % 4}.example.com"
217
+ # end
218
+ #
219
+ # Options:
220
+ #
221
+ # [ssl] Set to <code>true</code> to simulate a request via SSL. Defaults to
222
+ # <code>false</code>.
223
+ def self.compute_asset_host(asset_host, source, options={})
224
+ host = asset_host
225
+ if host.is_a?(Proc) || host.respond_to?(:call)
226
+ case host.is_a?(Proc) ?
227
+ host.arity : host.method(:call).arity
228
+ when 2
229
+ request = ActionController::Request.new(
230
+ 'HTTPS' => options[:ssl] ? 'on' : 'off')
231
+ host = host.call(source, request)
232
+ else
233
+ host = host.call(source)
234
+ end
235
+ else
236
+ host %= (source.hash % 4) if host =~ /%d/
237
+ end
238
+ host
239
+ end
240
+
241
+ # Returns <code>true</code> if the asset host differs between SSL and
242
+ # non-SSL pages, or <code>false</code> if the asset host doesn't change.
243
+ def self.ssl_asset_host_differs?
244
+ asset_host = ActionController::Base.asset_host
245
+ AssetHat.compute_asset_host(asset_host, 'x.png') !=
246
+ AssetHat.compute_asset_host(asset_host, 'x.png', :ssl => true)
247
+ end
248
+
165
249
  def self.clear_html_cache
166
250
  html_cache = {}
167
251
  end
@@ -3,11 +3,12 @@ Capistrano::Configuration.instance(:must_exist).load do
3
3
 
4
4
  namespace :deploy do
5
5
  namespace :asset_hat do
6
- desc 'Minify all CSS/JS with Asset Hat'
6
+ desc 'Minify all CSS/JS with AssetHat'
7
7
  task :minify, :roles => :assets, :except => {:no_release => true} do
8
8
  rake = fetch(:rake, "rake")
9
- env = fetch(:environment, fetch(:rails_env, "production"))
10
- run "cd #{current_path} ; #{rake} RAILS_ENV=#{env} asset_hat:minify"
9
+ env = fetch(:environment, fetch(:rails_env, "production"))
10
+ run "cd #{current_path} ; " +
11
+ "#{rake} RAILS_ENV=#{env} FORMAT=short asset_hat:minify"
11
12
  end
12
13
  end
13
14
  end
data/lib/asset_hat/css.rb CHANGED
@@ -25,25 +25,23 @@ module AssetHat
25
25
 
26
26
  engine = options[:engine].to_sym
27
27
  unless ENGINES.include?(engine)
28
- raise %Q{
28
+ raise %{
29
29
  Unknown CSS minification engine '#{engine}'.
30
30
  Allowed: #{ENGINES.map{ |e| "'#{e}'" }.join(', ')}
31
31
  }.strip.gsub(/\s+/, ' ') and return
32
32
  end
33
33
 
34
- AssetHat::CSS::Engines.send(engine, input_string)
34
+ AssetHat::CSS::Engines.send(engine, input_string).strip
35
35
  end
36
36
 
37
37
  # Given a string containing CSS, appends each referenced asset's last
38
38
  # commit ID to its URL, e.g.,
39
- # <code>background: url(/images/foo.png?ab12cd34e)</code>. This enables
39
+ # <code>background: url(/images/foo.png?ab12cd3)</code>. This enables
40
40
  # cache busting: If the user's browser has cached a copy of foo.png from a
41
41
  # previous deployment, this new URL forces the browser to ignore that
42
42
  # cache and request the latest version.
43
43
  def self.add_asset_commit_ids(css)
44
- css.gsub(/url[\s]*\((\/(images|htc)\/[^)]+)\)/) do |match|
45
- src = $1
46
-
44
+ update_css_urls(css, %w[images htc]) do |src, quote|
47
45
  # Get absolute path
48
46
  filepath = File.join(ASSETS_DIR, src)
49
47
 
@@ -51,7 +49,11 @@ module AssetHat
51
49
  filepath.sub!(/^#{FileUtils.pwd}#{File::SEPARATOR}/, '')
52
50
 
53
51
  commit_id = AssetHat.last_commit_id(filepath)
54
- commit_id.present? ? "url(#{src}?#{commit_id})" : "url(#{src})"
52
+ if commit_id.present?
53
+ "url(#{quote}#{src}#{src =~ /\?/ ? '&' : '?'}#{commit_id}#{quote})"
54
+ else
55
+ "url(#{quote}#{src}#{quote})"
56
+ end
55
57
  end
56
58
  end
57
59
 
@@ -59,26 +61,32 @@ module AssetHat
59
61
  #
60
62
  # - A string containing CSS;
61
63
  # - A string containing the app's asset host, e.g.,
62
- # 'http\://assets%d.example.com'. This value is typically taken from
64
+ # 'http\://cdn%d.example.com'. This value is typically taken from
63
65
  # <code>config.action_controller.asset_host</code> in
64
66
  # the app's <code>config/environments/production.rb</code>.
65
67
  #
66
68
  # An asset host is added to every image URL in the CSS, e.g.,
67
- # <code>background: url(http\://assets2.example.com/images/foo.png)</code>;
69
+ # <code>background: url(http\://cdn2.example.com/images/foo.png)</code>;
68
70
  # if <code>%d</code> in the asset host, it is replaced with an arbitrary
69
71
  # number in 0-3, inclusive.
70
- def self.add_asset_hosts(css, asset_host)
71
- return if asset_host.blank?
72
- css.gsub(/url[\s]*\((\/images\/[^)]+)\)/) do |match|
73
- # N.B.: The `/htc/` directory is excluded because IE 6, by default,
74
- # refuses to run .htc files (e.g., TwinHelix's iepngfix.htc) from
75
- # other domains, including CDN subdomains.
76
- src = $1
77
- "url(#{(asset_host =~ /%d/) ? asset_host % (src.hash % 4) : asset_host}#{src})"
72
+ #
73
+ # Options:
74
+ #
75
+ # [ssl] Set to <code>true</code> to simulate a request via SSL. Defaults
76
+ # to <code>false</code>.
77
+ def self.add_asset_hosts(css, asset_host, options={})
78
+ return css if asset_host.blank?
79
+
80
+ options.reverse_merge!(:ssl => false)
81
+
82
+ update_css_urls(css, %w[images]) do |src, quote|
83
+ computed_asset_host = AssetHat.compute_asset_host(
84
+ asset_host, src, options.slice(:ssl))
85
+ "url(#{quote}#{computed_asset_host}#{src}#{quote})"
78
86
  end
79
87
  end
80
88
 
81
- # Swappable CSS minification engines.
89
+ # Swappable CSS minification engines. Each accepts and returns a string.
82
90
  module Engines
83
91
  # Barebones CSS minification engine that only strips whitespace from the
84
92
  # start and end of every line, including linebreaks. For safety, doesn't
@@ -99,17 +107,58 @@ module AssetHat
99
107
  output.read
100
108
  end
101
109
 
102
- # CSS minification engine that simply uses the CSSMin gem, a Ruby port
110
+ # CSS minification engine that mostly uses the CSSMin gem, a Ruby port
103
111
  # of Lecomte's YUI Compressor and Schlueter's PHP cssmin.
104
112
  #
105
113
  # Sources:
106
114
  # - http://github.com/rgrove/cssmin
107
115
  # - http://rubygems.org/gems/cssmin
108
116
  def self.cssmin(input_string)
109
- CSSMin.minify(input_string)
117
+ output = CSSMin.minify(input_string)
118
+
119
+ # Remove rules that have empty declaration blocks
120
+ output.gsub!(/\}([^\}]+\{;\}){1,}/, '}')
121
+
122
+ output
110
123
  end
111
124
  end
112
125
 
126
+
127
+
128
+ private
129
+
130
+ # Strips any balanced quotation marks from `src`. Returns `src` and an
131
+ # instance of the quotation mark as two separate strings.
132
+ def self.separate_src_and_quotes(src)
133
+ quote = src[0, 1]
134
+
135
+ if %w[' "].include?(quote) && quote == src[-1, 1]
136
+ src = src[1, src.length - 2] # Strip quotes
137
+ else
138
+ quote = nil # No quotes in original CSS
139
+ end
140
+
141
+ [src, quote]
142
+ end
143
+
144
+ def self.update_css_urls(css, dirs, &css_block)
145
+ new_css = css.dup
146
+ dirs = dirs.join('|')
147
+
148
+ gsub_block = lambda do |match|
149
+ src, quote = separate_src_and_quotes($1)
150
+ css_block.call(src, quote)
151
+ end
152
+
153
+ # Match without quotes
154
+ new_css.gsub!(/url[\s]*\((\/(#{dirs})\/[^)'"]+)\)/, &gsub_block)
155
+
156
+ # Match with single/double quotes
157
+ new_css.gsub!(/url[\s]*\(((['"])\/(#{dirs})\/[^)]+\2)\)/, &gsub_block)
158
+
159
+ new_css
160
+ end
161
+
113
162
  end
114
163
 
115
164
  end