Tuesday, October 31, 2006

Rails Macro for JEdit

I have written a macro for JEdit that allows you to jump around from one related file to another in your Rails project. The behavior mimics some of the capability of the TextMate Rails bundle. This screencast shows the macro in action:

***Update - 07/04/08***
At long last I have finally decided to post this macro to a highly-available public repository. For the longest time, I have been hosting the zip file for this macro on my home network and many times the server was unavailable when someone needed it. No longer! You can download the macro from this github repo.

You'll want to copy the 'Rails' directory into your <home_dir>/.jedit/macros directory. You will need to have the Ruby and SideKick JEdit plugins as well as the "ruby" executable for your platform visible in the "path". This macro has been tested on Windows and Linux (OS X users will have to settle for TextMate ;-) ).

Saturday, July 29, 2006

My Ruby Stub

Being new to Ruby, one of the first things I wanted to do was figure out how to apply the testing style I am comfortable with in Java.  Several years ago, Bob Lee and I wrote an IDEA plugin to generate stub-object source files from interface definitions.  For a given interface:

The stub generator would create a class that looks like:

The generated stubs are useful in testing because I can set them up with a return value or exception to simulate some condition that I am trying to test. The methods of the stub keep track of whether they were called and any parameters that were passed to them. This approach follows the state-based testing that Fowler describes, and is central to my own programming style.

In Ruby, the same kind of thing can be accomplished at runtime in a very dynamic way. This unit test demonstrates the kind of thing I am looking for in a stub generator:

The Ruby Stub implementation was tricky to figure out until I learned how to use define_method:

So in my first real foray into a Ruby utility, I was able to create something that does what I need and learn a little about the API in the process. Of course, after savoring the feeling of learning and having written something that I thought was cool, I had a closer look the Stubba API from the Mocha library and realized that I still had a long way to go. Still, the exercise was a useful one; the more I use Ruby the more I really like it.

Wednesday, March 29, 2006


Last night, I attended a meeting of the St. Louis Ruby User Group. I was impressed by the size of the turnout. There were easily 30 people there in the empty, nondescript office space. Though the space was crappy, it felt more community-like than the Java SIG that is held every month in the much nicer CityPlace auditorium. As well, the attendence at the few JavaSIGs I have been to in the last year has been comparitively anemic - though the Java "community" is much larger in St. Louis, it doesn't have the continuing interest that this group seems to. I think of it like a new relationship with a pretty girl - everything feels new and interesting and there are is a lot to learn and talk about. At this point, Java is the spouse the community has had a relationship with for a long time and we have covered so many things that new conversations are harder to come by.