Ruby on Mac OS X Leopard with DTrace, XCode and Interface Builder support
Ruby itself was upgraded to 1.8.6 p36, which was the latest stable release that we could grab. We additionally merged patches for important bugs that were discovered after p36, but could not be part of an official Ruby patch release at that time (they actually were, but after our deadline).
The Ruby libruby.1.dylib library, which contains the core of the interpreter, is available as a 4-way fat universal binary, for the ppc, i386, ppc64 and x86_64 architectures. You can therefore embed Ruby in a 64-bit application. All C extensions are also available for both 32-bit and 64-bit architectures, except Tk which cannot go 64-bit. The Ruby interpreter launcher, /usr/bin/ruby, was therefore left 32-bit only to not break scripts that use the Tk extension, or any other 32-bit only dependency.
Ruby C extensions will by default compile 2-way fat, for ppc and i386. You can set the ARCHFLAGS environment variable to configure the build of an extension, if for example it links against a non-universal library (like the mysql.com binaries which are delivered per processor architecture).
Next to all these details, an interesting addition to the Ruby interpreter is support for DTrace static probes. DTrace was originally developed by Sun for Solaris, but is now being ported to other Unix versions as well. It allows to do low-overhead tracing and profiling of applications and even Operating System code. The Mac OS X Ruby interpreter includes these probes:
These were ported from Joyents Ruby DTrace project. Mac OS X Leopard also includes a tool called Instrument, which allows to visualize tracing and profiling events.
The probes that are currently in Ruby-DTrace
Probe name Description function-entry Probe that fires when a Ruby method is entered function-return Probe that fires when a Ruby method returns raise Probe that fires when a Ruby exception is raised rescue Probe that fires when a Ruby exception is rescued line Probe that fires for every line of Ruby executed gc-begin Probe that fires right before a GC cycle begins gc-end Probe that fires right after a GC cycle finishes object-create-start Probe that fires directly before a Ruby object is allocated object-create-done Probe that fires when Ruby is finished allocating an object object-free Probe that fires every time a Ruby object is freed ruby-probe Probe that can be fired from Ruby code (see below)
Apple also included Ruby support for XCode and the GUI Builder Interface Builder:
Xcode in Leopard comes with the RubyCocoa project templates, but also with a template to generate a Test/Unit target. Xcode also supports better Ruby auto-completion, driven by the BridgeSupport mechanism.Mac OS X Leopard also includes a new framework called Scripting Bridge which allows to script applications. Ruby is also supported:
Interface Builder now officially supports Ruby. For example, you can write a Ruby class in Xcode, with outlets and/or actions, and everything will automatically appears in IB. IB uses RubyCocoa's rb_nibtool utility to synchronize the metadata. On the other way, you can manually define outlets and/or actions in IB, drag-and-drop them in an Xcode Ruby file, and the corresponding Ruby code will be pasted in it.
ScriptingBridge is a new Leopard framework that provides access to the AppleEvent infrastructure, on which AppleScript is based. ScriptingBridge will dynamically generate an Objective-C interface that corresponds to the scriptable dictionary of a given application. You can then send messages and control this application from Objective-C.
Thanks to RubyCocoa, it is also possible to use ScriptingBridge from Ruby. Some scripting elements are not yet accessible though, like enumerations, but most of the functionality should be available.
Anatole Tresch Mar 03, 2015