Monday, September 12, 2005

Rake Hurdles

Before Rake is ready for prime time it is going to need some additional capabilities. Currently, the highest priority for me is CruiseControl.net integration. Creating IIS directories is another issue identified by my colleague Brent Cryder. Adding tasks to Rake will be easy, but I wonder what other common tasks will need to be added to Rake...

Thursday, September 08, 2005

Rails in School

From PragDave's blog:
"... I know of an undergraduate course in Scotland that will include a section using Ruby on Rails."
I wonder if college students can appreciate Ruby & Ruby on Rails. When I was in college there was a communications class that used Smalltalk. With little experience in different languages the joys of Smalltalk were easily lost on the students.

I wonder if it's possible to experience the happiness of Ruby without suffering through a few Java or C# projects.

Tuesday, September 06, 2005

Commit from a build file

Subversion comes standard with a command line client that can be used to commit changes. The usual sequence is add new files & remove deleted files, update from the repository, run the build file, and then commit to the repository. This sequence should be followed on every commit, and should be automated.

I've previously shown how easy it is to add & remove with Ruby. Update and commit can be executed in Ruby by `svn up` and `svn commit*` respectively.

All of these commands could be written into a rake build file as tasks. Each task would have pre-requisite tasks and execution will stop if any pre-requisite task fails. Rake supports this with it's dependency model. Expressing dependency in rake is easy.

task TaskName => [:pre-req1, :pre-req2, ...]

Therefore, the dependencies in our build file would look something like this:

task commit => [:test, :update]
task test => [:compile]
task update => [:add, :remove]


Compile, add & remove don't have any dependencies in our example, and are not shown.

The dependency model ensures a commit will not be executed unless all the pre-requisite tasks had been executed. Developers would be abstracted from this and could commit their changes by simply executing "rake commit" from the command line.

* Be sure to set the EDITOR environment variable. When the EDITOR variable is set any commit (without a message or file specified) will cause an editor window to open for you to enter a commit message.

Rake execution

I found a cool feature of rake recently:
"... no matter where you invoke it, rake always executes in the directory where the Rakefile is found. This keeps your path names consistent without depending on the current directory..." - Jim Weirich
Given the directory structure /trunk/src/project/build the rakefile will likely live in the /trunk directory. Because of the above quoted feature you can run rake in /trunk, /trunk/src, /trunk/src/project, or any child directory of trunk.