Saturday, April 11, 2009

Darren on Ruby: JGem, JRake... For Your Convenience

I have recently been investigating migrating RoR apps to JRoR, furthermore to Tomcat/JEE. This naturally means that I have both Ruby and JRuby installed at the same time, both on my PATH variable, meaning one takes precedence over the other; in my case Ruby comes first. Consequentially, I found myself typing in jruby -S gem ... or jruby -S rake ... a lot of the time and it started to annoy me. I took a look into the JRUBY_HOME\bin folder and discovered there is the jirb.bat script, obviously the JRuby equivalent to IRB. The inards are:
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"jruby.bat" -S "jirb" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"jruby.bat" "%~dpn0" %*
Pretty simple, ay? So what happens when you change the jirb to gem or rake? Exactly what you expect, lol. Go ahead and do it, save the files as jgem.bat and jrake.bat, respectively. You are now good to go. This should work for any executable-type script residing in your JRUBY_HOME\bin e.g. jwarble.bat. I'm not sure why the JRuby team did/do not distribute these scripts as standard, especially for gem and rake, as they are as common as irb. Anyway, enjoy.

No comments: