MacRuby for Application Scripting
MacRuby 0.6 was released a few days ago (30 April 2010). MacRuby is a version of Ruby 1.9, ported to run on the Mac OS X Objective-C common runtime. You can write Cocoa apps and, interestingly, you can also use ruby as a scripting language to control applications running on your system.
The MacRuby install includes macirb, the MacRuby equivalent of Ruby’s irb command line interpreter.Here is an example script to read from and control iTunes via the scripting bridge.
1 2 3 4 5
Here is an example script for Photoshop.
1 2 3 4
To see a list of what methods are available for an object, call its methods method as follows, subtracting out the methods available to Object.
Pretty cool stuff. I was never a big fan of AppleScript, and in fact stayed away from scripting Mac applications because I didn’t like using AppleScript. This, to me, changes the equation.