Nick Sieger: RubyConf: Mac OS X and Ruby tag:blog.nicksieger.com,2005:Typo Typo 2010-11-22T18:13:49+00:00 Nick urn:uuid:af12cc45-1478-4019-ab07-a5875de0d70b 2006-11-11T02:56:16+00:00 2010-11-22T18:13:49+00:00 Comment on RubyConf: Mac OS X and Ruby by Nick <p>I don&#8217;t know of any published information about this&#46; You might wish to contact Laurent to see what the timeframe is for this (I suspect we&#8217;d see something in Leopard or one of the updates to it)&#46;</p> Anonymous Coward urn:uuid:7026c986-947f-4e02-b1ea-5e7810d254d1 2006-11-11T01:10:36+00:00 2010-11-22T18:13:49+00:00 Comment on RubyConf: Mac OS X and Ruby by Anonymous Coward <p>Where can I find more information on Ruby&#46;framework?</p> cabo urn:uuid:0a4e2c9b-c421-4cee-80e6-fe02ed731d4b 2006-10-24T13:33:38+00:00 2010-11-22T18:13:49+00:00 Comment on RubyConf: Mac OS X and Ruby by cabo <p>Thanks, <em>has</em> &#45;&#45; no wonder I got confused if there are two things that are called RubyOSA&#46; Yes, your comment did help :&#45;)</p> has urn:uuid:6321d379-052e-4e18-9214-0251831af246 2006-10-23T17:40:20+00:00 2010-11-22T18:13:50+00:00 Comment on RubyConf: Mac OS X and Ruby by has <p>Reply to cabo:</p> <p>I&#8217;m not doing any comparisons of rb&#45;appscript and RubyOSA till RubyOSA 0&#46;1 is out and I&#8217;ve had a chance to look at it&#46; But to answer to the rest of your query:</p> <p>RubyOSA and rb&#45;appscript are both just bridges from the existing CRuby interpreter to OS X&#8217;s Apple Event Manager&#46; For attachability you need an OSA language &#45; essentially, a Ruby interpreter wrapped up as a Component Manager component&#46; (Same idea as ActiveScriptRuby, except ASR&#8217;s based on Windows COM, of course&#46;)</p> <p>You can get already a basic OSA component for Ruby, also called RubyOSA (no relation), from:</p> <p><a href='http://homepage' rel="nofollow">http://homepage</a>&#46;mac&#46;com/philip_aker/osa/osa&#46;html</p> <p>This supports the core OSA operations &#45; loading and storing OSA script files (&#46;scpt), compiling from source, and executing &#45; and should be adequate for simple tasks such as attaching alarm scripts to iCal&#46; However, it doesn&#8217;t support the more advanced OSA features such as sending and receiving events &#45;needed for things like Folder Actions and Mail rules &#45; so its usefulness is somewhat limited&#46;</p> <p>FWIW, I wouldn&#8217;t mind writing a full Ruby OSA component myself, but I&#8217;d need some help from a Ruby expert first as I don&#8217;t know anything about CRuby embedding&#46; (Offers welcome&#46;)</p> <p>HTH</p> cabo urn:uuid:7da199e3-c2b0-4d15-8080-6c71532a79c9 2006-10-23T11:20:06+00:00 2010-11-22T18:13:50+00:00 Comment on RubyConf: Mac OS X and Ruby by cabo <p>Question for the hallway: How do RubyOSA and rb&#45;appscript compare? The latter works well today, but does not support &#8220;attachability&#8221;, AFAIU&#46; But where do we go from here?</p> Nick Sieger urn:uuid:13013e7d-b186-4edb-aa5c-4a5fbfc82b4f 2006-10-21T18:58:33+00:00 2010-11-22T18:11:38+00:00 RubyConf: Mac OS X and Ruby <p><a href="http://chopine.be/lrz/diary/">Laurent Sansonetti</a>, who works at Apple Computer, is now in charge of maintaining Ruby inside the OS&#46;</p> <h2>History of Ruby in the OS</h2> <ul> <li>10&#46;2 shipped with Ruby 1&#46;6&#46;7</li> <li>10&#46;3 shipped with Ruby 1&#46;6&#46;8</li> <li>10&#46;4 shipped with 1&#46;8&#46;4, and the latest software update has Ruby fixes to allow compilation of C extensions</li> </ul> <p>Apple is actively looking to improve Ruby support in future versions of the OS in several areas:</p> <ul> <li>Ruby&#46;framework</li> <li>64 bit support</li> <li>Controlling scriptable applications</li> <li>Cocoa development</li> </ul> <h2>Framework</h2> <p>Why a framework? It&#8217;s easier for Mac development&#46; It allows multiple versions, and lets you bundle Ruby inside your application&#46; It&#8217;s also compatible with original layout <code>/usr/bin/ruby</code> =&gt; <code>/System/Library/Frameworks/Ruby.framework/Current/bin/ruby</code></p> <h2>Misc</h2> <ul> <li>Include IRB support, RubyGems, plus important gems: Rake, Rails, libxml2 and sqlite3 bindings, DNSSD (Zeroconf)</li> </ul> <h2>Controlling scriptable applications</h2> <p>Traditionally applications are scripted by AppleScript&#46; Apple Events are the IPC glue between the two&#46;</p> <p>RubyAEOSA is a Ruby wrapper for Apple events, that was started in 2001, but not active since 2003&#46; The code required is unnecesarrily verbose&#46; Instead, you could wrap and execute with AppleScript, but it&#8217;s slower and limited by knowledge of AppleScript&#46;</p> <p>RubyOSA is a new project created by Apple, intended to be a successor to RubyAEOSA, under active development and used today&#46; It has a much more Rubyish API, generating Ruby code on the fly and sending events lazily&#46; Apple events are completely hidden&#46;</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="ident">require</span> <span class="punct">'</span><span class="string">rbosa</span><span class="punct">'</span> <span class="ident">itunes</span> <span class="punct">=</span> <span class="constant">OSA</span><span class="punct">.</span><span class="ident">app</span><span class="punct">('</span><span class="string">itunes</span><span class="punct">')</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">current_track</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">current_track</span><span class="punct">.</span><span class="ident">name</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">current_track</span><span class="punct">.</span><span class="ident">artist</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">current_track</span><span class="punct">.</span><span class="ident">size</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">play</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">pause</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">sound_volume</span> <span class="punct">=</span> <span class="number">0</span> <span class="number">100</span><span class="punct">.</span><span class="ident">times</span> <span class="punct">{|</span><span class="ident">i</span><span class="punct">|</span> <span class="ident">itunes</span><span class="punct">.</span><span class="ident">sound_volume</span> <span class="punct">=</span> <span class="ident">i</span><span class="punct">;</span> <span class="ident">sleep</span> <span class="number">0.1</span> <span class="punct">}</span></code></pre></div> <p>0&#46;1&#46;0 release is coming soon, <code>gem install rubyosa</code>&#46;</p> <h2>Cocoa development</h2> <p>Mac development framework, mostly using Objective&#45;C&#46; RubyCocoa is a Ruby/Objective&#45;C bridge, now under active development with support from Apple&#46; It creates Obj&#45;C classes to Ruby proxies and vice&#45;versa&#46; Messages and exceptions are forwarded, and types are converted&#46;</p> <p>It uses a message convention&#46; &#8216;:&#8217; are substituted with &#8216;_&#8217; in the method name (selector)&#46; The final &#8216;_&#8217; can be omitted, but can lead to ambiguities&#46; It may be mandatory in a future release&#46;</p> <p>Some challenges remain in the Ruby/Obj&#45;C bridge&#46;</p> <p><em>Problem: Speed of method invocation&#46;</em> Solution: libffi from gcc, allows invocation of arbitrary foreign function interfaces&#46;</p> <p><em>Problem: Maintenance&#46;</em> Currently RubyCocoa needs to be rebuilt to take into consideration new APIs, so to solve, a metadata framework is being built to allow the information to be more dynamic, and a metadata generator tool will help with creating a metadata file for new APIs</p> <p>These latest developments are available from the <code>apple-unstable</code> branch in SVN from rubyforge&#46;</p> <h2>Future</h2> <ul> <li>&#8220;Toll free bridge&#8221; &#45;&#45; implement Ruby primitive types with CoreFoundation objects so that no type conversion is necessary</li> <li>Garbage collection &#45;&#45; Objective&#45;C will be getting garbage collection in the future, and the idea is to implement the Obj&#45;C garbage collector in Ruby through Obj&#45;C APIs&#46;</li> </ul>