Ship It! LIVEShip It! LIVE
home about services writing contact

We develop, test, and create fine software products, and design creative solutions to your problems.
The development of software is an intrinsically creative process. We are dedicated to improving our mastery of the art.
Links · RSS Feed
Popular Pages

More practical advice from the pragmatic crew. This is another excellent book from the guys at Pragmatic. In this book Jared and William cover pragmatic project management with down to earth advic...
-Jack D. Herrington
...It would be really nice if, as an industry, we could stop being such a bunch of screwed-up clowns and start living up to our potential. Ship It! is one of the things that could help, if only tho...
-Mike Gunderloy
Jared Richardson’s talk titled “Build Teams, not Products,” in particular, was one of the best presentations I’ve ever witnessed. It was just one of those talks where all the points seem tautologic...
-Yev Bronshteyn

Scripting OS X Applications with Ruby (Nov 20)

I needed to pull some statistics and information out of TextMate but they don't have a formal API. Then a co-worker spotted this project

http://blog.ardes.com/2007/9/14/os-x-textmate-user-free-time-tracker-matewatch

which has an example of the RubyOSA bridge that exposes the Apple events that an application makes available. That is to say, I can get access to tons of applications (including iTunes and TextMate) from a Ruby app.

RubyOSA is easy to use. Here's a quick example that shows the list of your TextMate documents.

require 'rubygems'
require 'rbosa'
tm = OSA.app("Textmate")
tm.documents.each{|doc|
 puts doc.name
}

Another scriptable application is iTunes. You can just as easily type

iTunes = OSA.app('iTunes')
iTunes.pause
iTunes.play

But the question you'll immediately have is what methods are availabe for iTunes or TextMate? For that you'll see the bundled rdoc-osa.

rdoc-osa will generate an HTML document (rdoc style) of the interfaces for any particular application. To create the TextMate documentation, just type:

rdoc-osa  --name TextMate

Then look in the doc folder for your index.html.

Also, be sure you install the RubyOSA gem first.

 sudo gem install rubyosa

For more information, see RubyOSA on Rubyforge or this page on the Apple Developer site.

Update: Thanks to reader Botond Orban for pointing out that the documentation command is rdoc-osa, not doc-osa. I'm not sure what I was thinking when I typed that! -jrr

Category: Ruby

New England Software Symposium (2008-09-12)
Back in Boston! I'll be speaking on Saturday and Sunday.
Pacific Northwest Software Symposium (2008-09-19)
Back on the west coast. I'll speak (and keynote) on Friday and Saturday in Redmond.
Agile Development Practices (2008-11-10)
Any conference in Orlando is good, but this one is great!
Agile One: Boston (2008-11-18)
The first Agile Experience was a huge success. Tell your manager about this one.


© 2007 Agile Artisans.