<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>jvoorhis comments on Last Night A Rake Task Saved My LIfe - Real World Project Automation With Rake</title>
    <link>http://www.jvoorhis.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>jvoorhis comments</description>
    <item>
      <title>"Last Night A Rake Task Saved My LIfe - Real World Project Automation With Rake" by jvoorhis</title>
      <description>&lt;p&gt;Here&amp;#8217;s a follow-up story about &lt;span class="caps"&gt;PLANET ARGON&lt;/span&gt;&amp;#8217;s asset compiler project in action.&lt;/p&gt;


	&lt;p&gt;In our client&amp;#8217;s application, an &lt;code&gt;Image&lt;/code&gt; model is created for each image they upload and the uploaded images are saved into an asset source directory. After the images are saved, an observer launches the build system, acting on any source images whose targets are missing.&lt;/p&gt;


	&lt;p&gt;While I was &lt;a href="http://www.jvoorhis.com/articles/2006/06/25/globalize-at-railsconf-streamlined-unveiled"&gt;speaking at Railsconf&lt;/a&gt;, a client of ours posted a bug to our Basecamp. For reasons I am still trying to determine, our client had uploaded four images to their application but the asset compiler task was not executed. It might take a minute to find the disconnect between my application and Rake, but our client needs those images that coincide with a press release as soon as we can deliver them.&lt;/p&gt;


Because asset compiler is build on top of Rake, it receives all of the benefits of Rake. I recalled that Rake supported a way to perform a dry run of a task execution (actually the option is called &lt;code&gt;--dry-run&lt;/code&gt;). Because each individual target file is a dependency of the top level task, &lt;code&gt;assets:build&lt;/code&gt;, running
&lt;pre&gt;&lt;code&gt;
rake assets:build --dry-run
&lt;/code&gt;&lt;/pre&gt;
tells me exactly which target files were missing. Sure enough, they coincided perfectly with the files the client reported were missing. By running
&lt;pre&gt;&lt;code&gt;rake assets:build --dry-run | grep "** Execute" 
&lt;/code&gt;&lt;/pre&gt;
I can ignore any file tasks which are not necessary. Within five minutes, I was able to diagnose the problem and allow my client to proceed after building the remaining target images and uploading them to the bandwidth provider, which was as simple as running
&lt;pre&gt;&lt;code&gt;
rake assets:build
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The beautiful thing here is how easy asset compiler lets me manage 4000 images. The application knows when to run build tasks, and in my &lt;code&gt;assets.rake&lt;/code&gt; file, I can concisely define 11 types of image transformations. I can run each type of transformation individually, or I can run them in one shot. Even better, since rebuilding all of the images takes considerable &lt;span class="caps"&gt;CPU&lt;/span&gt; power, I can rsync my asset source directory to a separate build server and run the build tasks there, exporting them to our web server and the bandwidth provider.&lt;/p&gt;


	&lt;p&gt;For those of you unfamiliar, the asset_compiler project is &lt;a href="http://www.planetargon.org/trac/wiki/AssetCompiler"&gt;hosted at planetargon.org&lt;/a&gt; and there is an &lt;a href="http://www.infoq.com/articles/Agile-Asset-Management"&gt;article on InfoQ&lt;/a&gt; that tells the story of its motivation and implementation. Asset compiler is free software.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;


Here is the amazingly helpful output I got from &lt;code&gt;rake assets:build --dry-run | grep "** Execute"&lt;/code&gt;.
&lt;pre&gt;&lt;code&gt;
** Execute (dry run) assets:navigation_icon:build
** Execute (dry run) assets:bronze_navigation_icon:build
** Execute (dry run) assets:navigation_icon_no_resize:build
** Execute (dry run) assets:bronze_navigation_icon_no_resize:build
** Execute (dry run) /path/to/assets/full_size/Ronaldo9mVert1.jpg
** Execute (dry run) /path/to/assets/assets/full_size/Ronaldo9mHoriz2.jpg
** Execute (dry run) /path/to/assets/assets/full_size/Ronaldo9mVert2.jpg
** Execute (dry run) /path/to/assets/assets/full_size/Ronaldo9mHoriz1.jpg
** Execute (dry run) assets:full_size:build
&amp;lt;snip /&amp;gt;
** Execute (dry run) assets:build
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;This is exactly the kind of clear and unambiguous feedback I like to see when investigating this kind of problem. A big thank you to Jim Weirich for his thoughtful implementation of Rake.&lt;/p&gt;

</description>
      <pubDate>Wed, 28 Jun 2006 15:14:00 NZST</pubDate>
      <guid>&lt;a href="/articles/2006/06/28/last-night-a-rake-task-saved-my-life-real-world-project-automation-with-rake"&gt;Last Night A Rake Task Saved My LIfe - Real World Project Automation With Rake&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2006/06/28/last-night-a-rake-task-saved-my-life-real-world-project-automation-with-rake"&gt;Last Night A Rake Task Saved My LIfe - Real World Project Automation With Rake&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
