Status
No public Twitter messages.
Location
Varanasi, India
Subscribe to GeoRSS Subscribe to KML


RubyCocoa

Published in Apple, Applescript, Mac OS X, Programming, Ruby  |  2 Comments


RubyCocoa is a bridge between the Mac OS X Cocoa Framework API that makes it callable from Ruby code. You can create applications, objects, call Mac OS X Services. You can even call Applescript:


require 'osx/cocoa'
include OSX
def speak (str)
  str.gsub! (/"/, '\"')
  src = %(say "#{str}")
  NSAppleScript.alloc.initWithSource(src).executeAndReturnError(nil)
end
speak "Hello World!"
speak "Kon nich Wah. Ogan key desu ka?"

Ben Bleything submitted a talk to RubyConf, titled “Harmonize: Exploiting RubyCocoa and Sync Services for Fun and Profit” where he discusses making a wrapper around the SyncAPI in Ruby. (blog post introducing Harmonize)

RubyCocoa looks like it may have stagnated a little as the last release was November 2005, but perhaps with such a renewed interest in Ruby, and Mac OS X gaining popularity, perhaps new life with be breathed into it. Projects such as SyncBridge and Harmonize also obviously help.

Update: Check out the very good examples and information at RubyCocoa.com, including how to use your Apple Remote from RubyCocoa .

Similar Posts


Responses

  1. jkh says:

    May 22nd, 2007 at 5:58 pm (#)

    RubyCocoa is far from stagnant – check out the 0.11 release which just went out today. There are a huge number of changes!

  2. Andrew says:

    May 22nd, 2007 at 6:06 pm (#)

    Hi JKH – I’m on the RubyCocoa mailing list and have seen the flurry of activity. I’ll try out the new release when I get a moment.

    I have run into a problem where RubyCocoa has prevented me from running ZenTest for Ruby on Rails development. Specifically, when I run ‘autotest’ I get:

    loading rspec_rails_autotest
    /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_import.rb:157: [BUG] Bus Error
    ruby 1.8.5 (2006-12-04) [i686-darwin8.8.2]

    Any Ideas?

Leave a Response