Vita Rara: A Life Uncommon

Get the Running Version of Groovy


Categories: |

This isn't documented in the Javadoc. (There is not javadoc on this method.) It seems to return the running version of Groovy when called:

org.codehaus.groovy.runtime.InvokerHelper.getVersion()

Helpful if you really need to know.

New iMac: Great Pairing Station?


Categories: | |

Looking at the new iMacs the 27" quad-core looks like it would make a superb pairing station for programming. I've been waiting to see what the update looked like before looking at end of year purchases. Here's how I see it:

Rspec & Shoulda: Specifying the Object Under Test


Categories: | |

Today we needed to test conditional validations on a model. We're using RSpec with the Shoulda macros to do this. Our model looks something like:

Just Say You're Sorry Already


Categories: |

As many know Matt, known as the Merbist, presented a risque set of slides at GoGaRuCo comparing software developers to porn stars. I'll leave as an act to the interested finding the slides.

The presentation somewhat, but the reaction of Matt and some other Rails leaders, DHH in particular, to the reactions of those who were offended by the presentation has engendered an uproar of significant proportions. On April 28th Matt posted his public response to the controversy, and later followed up with the following on twitter: "I obviously made a mistake. I didn't mean to offend anyone but since I did, I failed." Which he also posted to his blog as a followup to his previous public statement.

Introducing Modal Tracker: Intermodal Shipment Tracking Made Easy


Categories: | | | | |

Today is the day. I have been working on a new project called Modal Tracker. A system to track intermodal shipments. We are starting our FREE beta officially today.

Modal Tracker is an online system for tracking shipments done via steamship carriers. Modal Tracker features automatic updating of your shipment's information from online sources. You don't need to do the manual work. Modal Tracker is web-based software, so it's easy to get started. There's nothing to install. No servers to buy. Just enter a bill of lading number and you're started.

Shoulda: should_validate_uniqueness_of


Categories: | | |

When testing an ActiveRecord model that validates_uniqueness_of using Shoulda's should_validate_uniqueness_of macro it needs to be wrapped in a context where an instance of the model is created in the database. If there is no record in the database to validate against you'll get an error.

For more information see: Lighthouse Ticket.

Testing Non-Ruby Applications with Cucumber


Categories: | | | | |

Yesterday we got Cucumber working to test an older J2EE application that uses EJB 2.1 for its persistence layer. This application because of the J2EE EJB 2.1 beans has been very hard to near impossible to test in the past. I've been hearing about Cucumber for a while and we decided it was time to take a deeper look.

We plan on adding new features to this application using Rails, and over time porting the existing functionality to Rails. So, having a test suite written in Ruby that can test the application regardless of the underlying implementation was necessary. Cucumber with Webrat to the rescue. The general outline below will work with web applications written in any language. All of the interaction with the application happens at the HTTP protocol level.

Hpricot to Nokogiri Day 1


Categories: | |

Nokogiri's #xpath != Hpricot's #xpath

In Hpricot you can call xpath on a node to get the XPath that will retrieve that node from the document. In Nokogiri that equivalent is path.

I ran into this trying to figure out the xpath to a node in an HTML document. My normal routine is to load up the document in IRB and poke around to find the things I need.

Refactoring: Introduce Local Extension in Ruby


Categories: | |

I was recently reading Martin Fowler's Refactoring. While I was reading Introduce Local Extension (p. 164) all I could think of was how simple it is to implement in Ruby.

Motivation

As Fowler says in the motivation section writers of classes and libraries are not omniscient. Inevitably some class that you're using will be missing some feature you want. Using Introduce Local Extension you can add that additional functionality when you need it.

In a statically typed language, like Java, this refactoring would involve creating either a wrapping class or a descendent of the original class. In Ruby we will accomplish the same thing using a mixin.

Ruby Mastery: The Most Important Chapter You Can Read on Ruby


Categories: | |

There are a decent number of books out there on Ruby. In my mind I consider Chapter 11 of The Ruby Way, 2nd Edition the most important chapter you can read. Here's why.

Mastery in Ruby involves moving past regular programming and embracing the dynamic features of the language. The dynamic nature of Ruby goes far beyond dynamic typing. Frequently programmers coming to Ruby from languages like Java, C++/C#, PHP, VB.Net, and other statically and dynamically typed languages think that dynamic typing is the extent of what is dynamic about Ruby[1]. Chapter 11 of The Ruby Way will greatly disabuse them of this notion and put them on the pathway to Ruby mastery.