Ruby to Applescript

http://rb-appscript.rubyforge.org/

I thought this might be of interest to list readers. I used to do some
Applescripting and wonder whether there are projects where I might use
this.

Bill D. [email protected] wrote:

http://rb-appscript.rubyforge.org/

I thought this might be of interest to list readers. I used to do some
Applescripting and wonder whether there are projects where I might use
this.

You can use it anywhere you would have used AppleScript. That’s the
point. m.

matt neuburg wrote:

I thought this might be of interest to list readers. I used to do some
Applescripting and wonder whether there are projects where I might use
this.

You can use it anywhere you would have used AppleScript. That’s the
point. m.

To add to what Matt says:

Yes, rb-appscript lets you use Ruby anywhere you’d use AppleScript…
though with one caveat which I’ll explain in a tick. Python users are
already using py-appscript for everything from dinking about with their
iTunes playlist to driving professional publishing workflows - and
rb-appscript is just as capable as py-appscript is.

Also, one of the nice things about rb-appscript is that because it’s a
port and not a from-scratch development, it’s already almost as mature
as py-appscript is. Py-appscript’s already three years old, and has
been good enough for regular deployment for about the last two, so has
already been through a lot of field testing and refinement. There may
be the odd dumb bug introduced during porting, but once those are
shaken out (which won’t take long) you’ll be able to drop it in as an
AppleScript replacement with some confidence as to its reliability,
compatibility support, etc.


Now that caveat:

The one limitation is that Python/Ruby+appscript can’t [yet] replace
AppleScript for tasks where you need attachability support (e.g. Folder
Actions, Mail rules, iCal alarm scripts, Studio-based apps). You’d need
a full Ruby OSA language component to attach scripts to OSA-aware
applications, not just an Apple event bridge. There is a basic RubyOSA
available at http://homepage.mac.com/philip_aker/osa/osa.html, but it
provides only core functionality (load/store/compile/run), and not the
more advanced features like built-in support for sending and receiving
Apple events that most attachable apps require.

I have been looking into the possibility of writing a full Ruby OSA
component as well; however, I think the Ruby interpreter suffers at
least some of the same inherent limitations as the Python’s (global
interpreter state, can’t provide completely independent contexts for
each scripts due to low-level sharing of file handles, extensions).
This’d make it tricky to produce a really good, robust OSA Ruby - maybe
not impossible though given that ActiveScriptRuby (the Windows
equivalent) has [presumably] managed it.

Languages like JavaScript and Tcl are probably easier candidates for
OSA-ification, but given the popularity of Python and Ruby I would
still like to find a way to do those too. So if there’s any Ruby
embedding gurus around that’d like to discuss embedding options
further, then please get in touch.

Cheers,