# Ruby to Applescript

**URL:** <https://www.ruby-forum.com/t/ruby-to-applescript/71960>\
**Category:** Ruby\
**Created:** [October 12, 2006, 10:06pm UTC](https://www.ruby-forum.com/t/ruby-to-applescript/71960 "2006-10-12T22:06:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![devaulw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@devaulw](https://www.ruby-forum.com/u/devaulw)\
**Post date:** [October 12, 2006, 10:06pm UTC](https://www.ruby-forum.com/t/ruby-to-applescript/71960/1 "2006-10-12T22:06:05Z")

</div>

[http://rb-appscript.rubyforge.org/](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.

---

<div class="post-metadata">

**Author:** ![devaulw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@devaulw](https://www.ruby-forum.com/u/devaulw)\
**Post date:** [October 18, 2006, 10:39am UTC](https://www.ruby-forum.com/t/ruby-to-applescript/71960/2 "2006-10-18T10:39:42Z")

</div>

Bill D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://rb-appscript.rubyforge.org/](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.

---

<div class="post-metadata">

**Author:** ![devaulw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@devaulw](https://www.ruby-forum.com/u/devaulw)\
**Post date:** [October 18, 2006, 10:40am UTC](https://www.ruby-forum.com/t/ruby-to-applescript/71960/3 "2006-10-18T10:40:25Z")

</div>

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](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,
