Ruby as an AppleScript Replacement?
John Muchow has put together a three part (so far) set of blog posts that guides you through using Ruby as an alternative for AppleScript on OS X (part 1, part 2, part 3) using the rb-appscript library. It's very slow moving so even if you're a complete AppleScript / OS X newbie, you'll be able to follow it.
Ruby > AppleScript
With all of the developments going on between OS X and Ruby lately, I'm becoming convinced that Ruby could become the de-facto OS X scripting language of choice within the next few years. I'm a programmer, but I find AppleScript hideous enough to avoid it wherever possible, and I'm not the only one. I forget where, but I recently read an article about AppleScript that suggested while it reads like English, it's not particular easy to code in because it isn't English and the constructions are very rigid. Compare this AppleScript code:
tell application "TextEdit" get paragraph 1 of document "Read Me" end tell
To this Ruby alternative:
The AppleScript reads better in English terms, but the Ruby version is, arguably, easier to remember how to reconstruct, as long as you're familiar with Ruby syntax.
Ruby's reflection / inspection capabilities also ensure that even if you forget the name of a method / term, you can look it up on the fly! Try that in AppleScript! (Oops, I'm wrong, for now.)
As well as rb-appscript, let's not forget RubyOSA, a Ruby bridge to the Apple Event Manager, a library that makes controlling OS X applications child's play:
Justin Williams has put together an all-in-one RubyOSA tutorial that's worth reading and demonstrates how to control NetNewsWire from Ruby.
Ruby & OS X Books?
Lastly, where are the Ruby and OS X books? Are you writing one now that you can tell us about? Are you a publisher looking for someone to write such a book? Is there already a book that's dedicated to using Ruby specifically with OS X? If not, it's finally time for one.