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

Ship It! is part manual of best practices, part software methodologies book and part a distillation of ideas and experiences of good and bad projects that the authors have been involved in. It migh...
-Tech Book Report
...Much like the Mac, this book “just works”, because it takes the best from lessons learned from team leaders and team players and takes the mystery out of the project management processes as appl...
-Robert Pritchett
..."Ship It!" is in the style of the other Pragmatic books and is an easy and focused read. I finished it in two days and have already gained a wealth of insight that I can apply immediately. Hig...
-Anil John

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

Agile Tour (2010-10-28)
This will be a great collection of speakers on Agile and business topics.
Indie Conf (2010-11-13)
I'll be talking about keeping your skills current at this conference for independent web developers
Agile Dev Practices East (2010-11-14)
This world-class conference in Orlando always has a great mix of speakers and attendees. Don't miss it!


© 2007 Agile Artisans.