Article

The Power of Ruby OSA

Posted  by Blake Watters.

PublicCategorized as Near-Time.

Tagged with ruby and subversion.

Today I discovered the excellent RubyOSA library. It bridges Mac OS X’s Open Scripting Architecture. It allows you to simply script many Cocoa applications. The coolest part is that it can generate RDoc documentation against any OSA application on your system. I generated documentation for Adium, my chat client of choice. Five minutes later I had connected Adium’s status message to my Subversion repository’s trunk revision number. Here’s the code (with repository randomized):


require ‘rubygems’
require ‘rbosa’
require ‘rexml/document’
app = OSA.app(‘Adium’)
doc = REXML::Document.new(`svn—xml info https://fake.near-time.subversion-server.com/svn/near-time/trunk`)
revision = doc.root.elements["//commit"].attributes[‘revision’]
app.adium_controller.my_status_message = "Current Near-Time Revision: #{revision}"

How’s that for return on lines of code? Ruby and OS X are amazing!


Arrow_down Hide comments

Powered by Strategy-NetsTerms of Services | Privacy Policy | Security Policy |