| Path: | README |
| Last Update: | Mon May 08 10:50:52 PDT 2006 |
An asset compiler is a build system which transforms a set of media files into the format required by a software project. This asset compiler in particular is a lightweight DSL for defining the necessary build tasks with Rake.
Trivial example for copying a directory of assets:
asset_task 'old_war_films' do
from Rake::FileList[SRC_DIR + '/*.mov']
to BUILD_DIR
transformation do |src, target|
cp src, target
end
end
This example defines the following tasks:
rake assets:build # Build all assets rake assets:clobber # Clobber all assets rake assets:old_war_films:build # Build the old_war_films files rake assets:old_war_films:clobber # Remove old_war_films files rake assets:old_war_films:rebuild # Force a rebuild of the old_war_films files rake assets:rebuild # Rebuild all assets
Here is an example that applies a sepia effect to each image in a directory and crops them to 62x62 pixels:
define_image_transformation 'thumbnailize' do
crop_to '62x62', :north
end
define_image_transformation 'sepia' do
greyscale
# r g b tint
tint 0.40, 0.25, 0.25, '#eeb030'
end
image_task 'thumbnails' do
from SRC_DIR
to BUILD_DIR
transformation do
sepia
thumbnailize
end
end
This will define the following tasks:
rake assets:build # Build all assets rake assets:clobber # Clobber all assets rake assets:thumbnails:build # Build the thumbnails files rake assets:thumbnails:clobber # Remove thumbnails files rake assets:thumbnails:rebuild # Force a rebuild of the thumbnails files rake assets:rebuild # Rebuild all assets