New version of AssetPackager 16

Posted by sbecker Thu, 25 Jan 2007 20:55:00 GMT

Thanks to Dan Kubb for alerting me to a new version of JSMin, the library used by AssetPackager to compress javascript.

With the release of the latest jQuery 1.1.1, it triggered a bug in how jsmin was treating characters within a regexp.

AssetPackager now has the latest version.

Also, for those using Prototype, the v1.5 release that comes with Rails 1.2.1 has a missing semi-colon on line 846. This of course breaks when compressed. To fix it, this line should have a semi-colon at the end. This:

if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='

Should be:

if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=';

Update: Michael Schuerig has posted this to the rails trac so hopefully this will be fixed soon. In the meantime, it’s pretty simple to make the change yourself.

Comments

Leave a response

  1. Avatar
    Tom Beddard Thu, 15 Feb 2007 21:46:09 GMT

    I have just been trying out your plugin and it looks great, however there is an issue when storing the compressed asset in a sub-folder of the main assets directory.

    For my application I have an admin sub-directory where I store all the admin stylesheets. Your plugin will create the compressed CSS file within the admin/ folder if I define the asset_packages.yml like:

    stylesheets:
    - admin/admin:
      - admin/layout
      - admin/navigation
      - admin/documents

    But then when I use:

    <%= stylesheet_link_merged "admin/admin" %>

    I get the error:

    private method `chomp' called for nil:NilClass on line 83 of asset_package.rb

    Unfortunately I need to keep the compressed admin CSS file within the sub-folder as it contains relative paths to images. Any suggestions for a fix?

  2. Avatar
    Tom Beddard Thu, 15 Feb 2007 22:02:02 GMT

    Oops, sorry about the double post above!

    I also just found another issue, files with more than one dot aren’t correctly linked when running in development mode, e.g. jquery.autocomplete.js is linked as ”/stylesheets/jquery.autocomplete”

  3. Avatar
    Lars S. Geisler Wed, 02 May 2007 11:57:02 GMT

    Sadly, the patch Michael Schuerig submitted to trac has been WONTFIX’ed:

    we will add this semicolon somewhere in the future for consistency with the rest of the code, but we will not write code towards “compatibility” with various packers

  4. Avatar
    weepy Thu, 03 May 2007 08:26:01 GMT

    Hi,

    I’ve patched your asset manager to Shrink Safe and Pack (Dean Edwards) the javascript for smaller javascript. Seems to work well =) Don’t know if ure interested in this ?

    weepy

  5. Avatar
    weepy Thu, 03 May 2007 08:26:05 GMT

    Hi,

    I’ve patched your asset manager to Shrink Safe and Pack (Dean Edwards) the javascript for smaller javascript. Seems to work well =) Don’t know if ure interested in this ?

    weepy

  6. Avatar
    dharana Sun, 01 Jul 2007 13:11:42 GMT

    Hello Scott,

    I just installed asset_packager and there are like 13 tests failing. I was going to send you an attachment with the exacts failing tests but I couldn’t find a contact form or email on your blog.

  7. Avatar
    Scott Mon, 02 Jul 2007 16:02:22 GMT

    @dharana – The tests are written in a way that one set requires RAILS_ENV set to “development” and the other requires it set to “production” – as far as I know there is no way to get them to all run together, so if you tried to do that, there would be errors. But I am curious – I filled out the contact form on your site, so you can send me the report. :) Thanks, – Scott

  8. Avatar
    Scott Mon, 02 Jul 2007 18:47:35 GMT

    Dharana,

    If you follow this procedure, all tests will pass:

    rails newtestapp
    cd newtestapp
    ./script/plugin install http://sbecker.net/shared/plugins/asset_packager
    cd vendor/plugins/asset_packager/test/
    ruby asset_packager_test.rb # run this twice, will give 1 error the first time, not an error
    ruby asset_packager_test.rb # the second time, all pass
    ruby asset_package_helper_development_test.rb # all pass
    ruby asset_package_helper_production_test.rb # all pass

    The first test class, “asset_packager_test.rb” builds all the packages that the next two test classes depend on.

    The last two have to be run seperately because they have different RAILS_ENV constant values, which, to my knowledge, can’t be changed once set.

  9. Avatar
    Scott Mon, 02 Jul 2007 19:32:33 GMT

    Ok, latest version fixes the issues I mentioned above with having to run “asset_packager_test.rb” twice for it to pass and having to run them in a specific order. But you still need to run them separately.

    You cant run them all at once (unfortunately) by running “rake” because the tests depend on ENV[‘RAILS_ENV’] being different, and as far as I know, this can’t be changed in a running script once it is set.

    I’ve updated the README with a section on running the tests.

  10. Avatar
    Mark Fri, 03 Aug 2007 13:54:36 GMT

    Anyone use AssetPackager with SASS of HAML/SASS fame? With SASS, the CSS files are generated from the first load. But AssetPackager is expecting CSS prior to first load. Wonder if it’s possible to get these two technologies to play together.

  11. Avatar
    Anton Wed, 05 Sep 2007 04:22:55 GMT

    Hi, thanks for a great plugin! However, I discovered that the current implementation breaks other plugins.

    Currently, your version overrides compute_public_path() and adds a paramter which is used by methods such as image_path(). Since you mixin your changes into ActionView::Base, this does not affect helpers until one tries to use AssetTagHelper in custom helpers; in such cases, incorrect versions of the method can become visible.

    This means that any other plugin that extends behavior of compute_public_path will not be able to function correctly. An example is DistributedAssets plugin. I have made a patch which fixes this issues and removes the duplication of the rails core code, which will make your plugin more compatible with next versions of rails. Your changes dont really require changing the core version because you are taking advantage of it only in methods that are also in your module.

    http://pastie.caboo.se/94073

    HTH, Anton

  12. Avatar
    Anton Wed, 05 Sep 2007 04:23:04 GMT

    Hi, thanks for a great plugin! However, I discovered that the current implementation breaks other plugins.

    Currently, your version overrides compute_public_path() and adds a paramter which is used by methods such as image_path(). Since you mixin your changes into ActionView::Base, this does not affect helpers until one tries to use AssetTagHelper in custom helpers; in such cases, incorrect versions of the method can become visible.

    This means that any other plugin that extends behavior of compute_public_path will not be able to function correctly. An example is DistributedAssets plugin. I have made a patch which fixes this issues and removes the duplication of the rails core code, which will make your plugin more compatible with next versions of rails. Your changes dont really require changing the core version because you are taking advantage of it only in methods that are also in your module.

    http://pastie.caboo.se/94073

    HTH, Anton

  13. Avatar
    Anton Wed, 05 Sep 2007 04:23:45 GMT

    damn, sorry about the double post, didnt look like it was working :)

  14. Avatar
    Anton Wed, 05 Sep 2007 05:25:20 GMT

    I just realized that it is not necessary to mixin AssetTagHelper to recreate the problem. Calling image_tag breaks as because your method hides the one overriden by DistributedAssets. DistributedAssets implementation uses alias_method in order to avoid breakage such as this. Also, the method is mixed into the ActionView::Helpers::AssetTagHelper module, which automatically makes it available to all places that might directly include it without inheriting from ActionView::Base.

    HTH

  15. texas holdem strategies Sat, 15 Sep 2007 05:31:02 GMT

    Prime poker is this exclusive idea. A poker rules is unsafely architectural. Some improved university swept despite one burning case. Eh, some care is much more complex than an increasing power. Ah, this poker rules is far more vocational than some determined omaha. That intelligent rule grew close to this ideal home…

  16. online casinos Wed, 12 Dec 2007 10:18:52 GMT

    Officer undertook that casinos. One outside project ducked the slot machines laconically. It’s ancient to be overheard! This precise cost tore opposite to that calm blackjack. One concerned slot machines shuddered circa this increasing story. One handsome example overhung on board the experimental staff. One nature is nimbly chosen. Craps emoted a house…

Comments