{"id":181,"date":"2006-10-24T10:06:09","date_gmt":"2006-10-24T15:06:09","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/index.php\/2006\/10\/24\/rubyconf-leveraging-mac-os-x-from-ruby\/"},"modified":"2006-10-24T10:06:09","modified_gmt":"2006-10-24T15:06:09","slug":"rubyconf-leveraging-mac-os-x-from-ruby","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2006\/10\/24\/rubyconf-leveraging-mac-os-x-from-ruby\/","title":{"rendered":"RubyConf: Leveraging Mac OS X From Ruby"},"content":{"rendered":"<p><a href=\"http:\/\/chopine.be\/lrz\/diary\/\">Laurent Sansonetti<\/a> of Apple gave an awesome presentation on <a href=\"http:\/\/rubyosa.rubyforge.org\/\">RubyOSA<\/a>.  RubyOSA is a Ruby\/AppleEvent bridge that allows Ruby programs to interact and manipulate Apple applications in the same fashion that <a href=\"http:\/\/www.apple.com\/macosx\/features\/applescript\/\">AppleScript<\/a> can.  Here is a code sample from the RubyOSA site:<\/p>\n<p>[source:ruby]<br \/>\nrequire &#8216;rbosa&#8217;<br \/>\napp = OSA.app_with_name(&#8216;iTunes&#8217;)<br \/>\ntrack = app.current_track<br \/>\np track # -&gt; #&lt;OSA::Itunes::File_track:0x1495e20&gt;<br \/>\np track.name # -&gt; &#8220;Over The Rainbow&#8221;<br \/>\np track.artist # -&gt; &#8220;Keith Jarrett&#8221;<br \/>\np track.duration # -&gt; 362<br \/>\np track.date_added.to_s # -&gt; &#8220;2006-06-30&#8221;<br \/>\np track.enabled? # -&gt; true<br \/>\n[\/source]<\/p>\n<p>According to Laurent, Ruby has been shipped with OS X since 10.2, &#8216;Jaguar&#8217; which buncled Ruby 1.6.7.  Apple packages Ruby as a framework which is easier for <b>Mac<\/b> development and allows versioning.  In addition to Ruby, OS X includes RubyGems and gems like rake, rails and friends (mongrel, capistrano), libxml2, and sqlite3.  Laurent mentioned that he is open to suggestions for adding including additional gems into OS X.<br \/>\n<!--more--><br \/>\nFor sometime Apple has allowed Mac developers to programmatically control Mac applications via AppleScript.  Now Ruby\/Mac developers have that same power via RubyOSA.  Laurent gave a powerful demo where he controlled his iTunes from Ruby&#8217;s <b>irb<\/b>.  He was able to play, pause, and stop a song.  He was able to list his play iTunes playlists.<\/p>\n<p>Laurent topped off his irb\/iTunes demo by writing an Ruby\/Cocoa UI application that controlled iTunes.  Cocoa is a UI framework for building Mac applications, often with Object-C.  Laurent described a Ruby\/Object-C which allows Ruby developers to create Cocoa applications for the Mac.  if you want to get started with prototyping Mac applications with Ruby direct your browser to <a href=\"http:\/\/www.rubycocoa.com\/\">RubyCocoa<\/a>.  Apple also has a lot of Cocoa reference material at their <a href=\"http:\/\/developer.apple.com\/cocoa\/\">Cocoa developer<\/a> site.<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/ruby\" rel=\"tag\">ruby<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rubyconf\" rel=\"tag\"> rubyconf<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rubyconf2006\" rel=\"tag\"> rubyconf2006<\/a>, <a href=\"http:\/\/technorati.com\/tag\/mac\" rel=\"tag\"> mac<\/a>, <a href=\"http:\/\/technorati.com\/tag\/cocoa\" rel=\"tag\"> cocoa<\/a>, <a href=\"http:\/\/technorati.com\/tag\/ui\" rel=\"tag\"> ui<\/a>, <a href=\"http:\/\/technorati.com\/tag\/itunes\" rel=\"tag\"> itunes<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rubyosa\" rel=\"tag\"> rubyosa<\/a>, <a href=\"http:\/\/technorati.com\/tag\/rbosa\" rel=\"tag\"> rbosa<\/a>, <a href=\"http:\/\/technorati.com\/tag\/object-c\" rel=\"tag\"> object-c<\/a>, <a href=\"http:\/\/technorati.com\/tag\/osx\" rel=\"tag\"> osx<\/a>, <a href=\"http:\/\/technorati.com\/tag\/os+x\" rel=\"tag\"> os x<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laurent Sansonetti of Apple gave an awesome presentation on RubyOSA. RubyOSA is a Ruby\/AppleEvent bridge that allows Ruby programs to interact and manipulate Apple applications in the same fashion that AppleScript can. Here is a code sample from the RubyOSA site: [source:ruby] require &#8216;rbosa&#8217; app = OSA.app_with_name(&#8216;iTunes&#8217;) track = app.current_track p track # -&gt; #&lt;OSA::Itunes::File_track:0x1495e20&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[17,22,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-2V","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/181"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}