Sunday, June 24, 2007

CruiseControl.rb and RCov Are SO Good Together

I spent a bit of time this morning getting CruiseControl.rb and RCov working together for a new client's fairly LARGE Ruby on Rails (70+ models, 40+ controllers) project. If you are not familiar with CruiseControl.rb, it is the Ruby based continuous integration tool from ThoughtWorks. RCov, on the other hand, is a very well known code coverage tool for Ruby. The implementation was incredibly simple, but finding the information on how to get the two working together required a perusal of the CruiseControl.rb code itself.

First of all, you will need to install the rails_rcov plugin. This useful plugin allows you to really easily run RCov using rake, and is essential to simple RCov integration with your CruiseControl.rb builds. You can install rails_rcov like this:

./script/plugin install

Use the "-x" option if you want to use an svn:external link to the latest version of the plugin. I personally don't like to do that...I want control over when the software I am using gets updated, thanks.

Once the plugin is installed into your project you have some useful rake tasks like this one:

# sort by coverage
rake test:units:rcov RCOV_PARAMS="--sort=coverage"

Now you are ready for the final bit, which is adding a "cruise.rake" task to the "lib/tasks" directory of your Ruby on Rails project. The task should have something like this, which was lifted verbatim from the CruiseControl.rb build of CruiseControl.rb itself (that all sounds kinda twisted, but it is cool):

desc 'Continuous build target'
task :cruise do
mkdir_p out unless out if out

ENV['SHOW_ONLY'] = 'models,lib,helpers'
mv 'coverage/units', "#{out}/unit test coverage" if out

ENV['SHOW_ONLY'] = 'controllers'
mv 'coverage/functionals', "#{out}/functional test coverage" if out


That's it. Now you have incredible code coverage goodness right within your build. You can even browse the source within the browser window of the CruiseControl.rb dashboard and see which lines of code were covered by your tests, and which were not...

So if you have a Ruby on Rails project, with a project team of greater than 1 developer, you had better start using CruiseControl.rb. It is too easy, and the payoff of doing continuous integration is huge!

Thursday, June 14, 2007

A Little Bit Of Merb In Los Angeles

Last night, I gave a short presentation on Ezra Z's cool Ruby web development framework Merb at the Los Angeles Web Developer Meetup. Microsoft was kind enough to provide space at their new downtown offices, and even buy pizza. Can you say "(munch munch) Silver (crunch) light (munch) launch (gulp) budget"?

When I started my presentation, I asked the room how many people were using Ruby on Rails. Almost everyone in the place raised their hand. Nice! My talk was a brief review of what Merb is, and some of the similarities and differences with Rails. The crowd was very attentive, and there were some good followup questions asked afterward.

Anyone who is interested in the slides from my presentation, they are available here.

There were also presentations by Ari Lerner about Ruby metaprogramming, and Ben Sandofsky on the Seaside web framework. I especially liked the example that Ben used to illustrate continuations.

Lastly was Woody Pewitt, the Microsoftie tasked with demoing Silverlight. It was funny how long it took their poor projector to recover when he plugged in his Vista notebook to show his demo, given that every other presenter was using a Mac. Woody was a good sport about it, and there really is a lot of interest in Silverlight right now, so I saw a number of people talking to him after the demo.

Anyhow, a good time was had by all, and I am looking forward to the next one. Here in L.A. we have a thriving little tech scene of our own, albeit not as huge as the bay. But don't count us out!

Without Air, No One Can Hear You Scream

I was shocked to read about the ongoing problems with the life support computers onboard the International Space Station. Every time I hear of problems up there, I feel a serious rant coming on.

I grew up on science fiction books. In fact, I would have to say that the vast majority of my childhood was spent far away from this planet. Suffice to say, I am a serious supporter of space exploration.

But this madness with the ISS is about more than I can take. Between the noise, the need to keep reboosting its orbit, and the lack of any real scientific value, we really SHOULD abandon ship at this point!

Friday, June 01, 2007

Microsoft Vs. The Galaxy

"The more you tighten your grip...the more star systems will slip through your fingers..." - Princess Leia

Power Rangers Should Test First

Last night, I got home a bit late. My 8 year old son was still up, watching the Power Rangers. "Sit down and watch with me, Dad," he said. "I'm surprised you still like the Power Rangers," I said, as I sat beside him on the sofa. "I mostly just like the vehicles," he told me.

The Power Rangers were in trouble in this episode. The bad guys had taken remote control of the Rangers' giant robots, and the Power Rangers were helpless without their usual firepower. The Smart Rangers, meaning the guy with the glasses and the Asian girl (WTF!!!), were constructing a jamming device to block the bad guy's signal, while the other Rangers got their behinds handed to them by their own robots.

"OK, that finishes it. Let's go!" exclaimed Glasses Ranger as he attached the last part to the jamming box. They rushed off to the scene of the battle. "I hope this works," said Glasses Ranger and pushed the button. Nothing happened. "Oh no, what could be wrong?!" cried out the Smart Rangers.

My son, who had been quietly watching all of this, suddenly spoke out. "They're stupid. They should have tested it first."