Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
271 lines (154 sloc) 5.64 KB


Downloads/updates assets. Any framework*.

  • But if you're using sprockets/rails pipeline there's more sugar.


gem install assetify


On any project`s root:


This will create a Assetfile if not found.


Like a Gemfile, but with fewer chars. Only one actually.

Behold the 'a'

a  "tipsy", "http://...tipsy.js"
a  "tipsy", "http://...tipsy.css"
a  "video", ""

There's also an alias 'asset' for 'a', if you enjoy typing.

asset "tipsy", "http://...tipsy.js"

You can choose the filetype (or extension) before too:

type "name", "url", <"version"> or <:options>

js "jquery", "{VERSION}.min.js", "1.6"
js "tipsy",  ""


css "tipsy", ""

Any file:

mp3 "alert", "http://link/to/audio"

Now just run assetify to make sure everything is installed/up-to-date.


Use groups/namespaces to group related assets together:

group "forms" do
  js "validator", url
  js "textmask",  url

This will install as "vendor/assets/javascripts/forms/validator.js"

You can nest groups too:

group "forms" do
  js "validator", url
  group "extra" do
    js "another", url


Big projects makes you download tons of files for some .min files and css.

pkg "fancy", "" do
  js  "cool", "internal/js/cool.js"
  css "cool", "internal/css/cool.css"

This downloads and 'cherry pick' the files. Files will be written with the namespace "fancy":


You can pass :shallow => true to avoid the namespace:

pkg "fancy", "", shallow: true do

Results in:


Also, please check out the note about link inside pkgs below.


You can resource a full directory of files, too. Very useful when dealing with pkgs:

pkg "complexfw", "link" do
  js  "complex.min.js"
  dir "images/", to: "images/complexfw"
  # Another option, treat`em all as filetype:
  dir "src/", :as => :js

All files inside images will be copied to "images/complexfw" and all files in 'src' to 'javascripts' (or whatever else jspath is).

Note: Have in mind that the "link" inside dir/packages is a regex that returns the first match inside the archive. Check out libarchive or the pkg.rb source for more info.


Or The Rails 3.1+ Asset Pipeline.

Wouldn`t it be nice to bundle all those little dependencies and tiny stylesheets to avoid extra includes, but, change the source on every update...PITA. No worries:

CSS will be converted to sass, scss or erb (defaults), your choice. And every path corrected to use the pipeline.

Jquery Mobile example:

pkg :mobile, "", shallow: true do
  js  "mobile", "mobile.js"
  css "mobile", "mobile.css", :as => :sass
  dir "images/*"

You just need:

//= require 'mobile'

On application.css and application.js.

Images will be in 'vendor/assets/mobile/', and the paths inside mobile.css corrected to 'image-url(mobile/)', or <%%> if I`ve had choose erb.

This means you can have any third party library in the format you like, always up-to-date. Easy to copy and customize parts of the code.


You can convert your assets to coffescript, sass or scss:

 js "fulib", "http....", :as => :coffee
 css "1140", "http....", :as => :sass
 css "1140", "http....", :as => :scss

Note: You do need aditional stuff for this. Gem 'sass' and/or node`s 'js2coffee' (install via npm).


Preprocess images is also possible:

png "logo", "http....", :as => :jpg, :quality => 75

Note: Need to install 'imagemagick' and 'minimagick' gem for this.


Assetify first tries to recognizes the file as text or binary. If the file is human readable, try a (X.X.Xxx?) pattern match that if found it`s used. Otherwise go for md5sum.


Set a different location per file:

js "other", "http://lib.../other.js", to: "different/path"

Filename will be: ./different/path/other.js This works for namespaces too, change "to" with "ns".


Change some default settings:

newname      true || false
javascripts  "public/javascripts"
stylesheets  "public/stylesheets"
images       "public/images"

If newname is set to true (default) the file will be renamed. Ex:

js "validator", "http//.../jquery.validator.min.js"

Filename will be: "validator.js"


Out of the box support for rails 3.1, defaults to 'vendor/assets'. Rails 3.0< users should change the options as above.


Use ruby syntax for nice colors:

(add-to-list 'auto-mode-alist '("Assetfile$" . ruby-mode))


  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright (c) 2011 Marcos Piccinini. See LICENSE.txt for further details.

Jump to Line
Something went wrong with that request. Please try again.