<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>MacRuby.tmbundle</title>
 <link href="http://drnic.github.com/macruby-tmbundle/atom.xml" rel="self"/>
 <link href="http://drnic.github.com/macruby-tmbundle/"/>
 <updated>2008-12-29T01:52:17-08:00</updated>
 <id>http://drnic.github.com/macruby-tmbundle/</id>
 <author>
   <name>Dr Nic Williams</name>
   <email>drnicwilliams@gmail.com</email>
 </author>

 
 <entry>
   <title>Create MacRuby methods from Objective-C signatures</title>
   <link href="http://drnic.github.com/macruby-tmbundle/2008/12/29/create-macruby-methods-from-objective-c-signatures.html"/>
   <updated>2008-12-29T00:00:00-08:00</updated>
   <id>http://drnic.github.com/macruby-tmbundle/2008/12/29/create-macruby-methods-from-objective-c-signatures</id>
   <content type="html">&lt;p&gt;The MacRuby.tmbundle now supports a feature first introduced into the RubyCocoa.tmbundle: the ability to create new methods from Objective-C signatures.&lt;/p&gt;

&lt;p&gt;To create new methods in Ruby, you can type &#8216;def&#8217; and TAB. Now, if you copy the signature of an Objective-C method into the clipboard you can create a MacRuby version of it with the &#8216;m&#8217; snippet.&lt;/p&gt;

&lt;p&gt;See samples (or &lt;a href='http://gist.github.com/41232'&gt;gist&lt;/a&gt;):&lt;/p&gt;
&lt;notextile&gt;&lt;div class='highlight'&gt;&lt;pre&gt;&lt;span class='k'&gt;class&lt;/span&gt; &lt;span class='nc'&gt;SpeechController&lt;/span&gt;
  &lt;span class='c1'&gt;# from - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender willSpeakWord:(NSRange)wordToSpeak ofString:(NSString *)text&lt;/span&gt;
  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;speechSynthesizer&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;sender&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;willSpeakWord&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;wordToSpeak&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;ofString&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;text&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  
  &lt;span class='k'&gt;end&lt;/span&gt;

  &lt;span class='c1'&gt;# from speechSynthesizer:willSpeakWord:ofString:&lt;/span&gt;
  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;speechSynthesizer&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;speechSynthesizer&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;willSpeakWord&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;speakWord&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;ofString&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;string&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
    
  &lt;span class='k'&gt;end&lt;/span&gt;
  
  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;someMethod&lt;/span&gt;
    &lt;span class='c1'&gt;# self.m expanded becomes&lt;/span&gt;
    &lt;span class='nb'&gt;self&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;speechSynthesizer&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;sender&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;willSpeakWord&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;wordToSpeak&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;ofString&lt;/span&gt;&lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;text&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/notextile&gt;
&lt;p&gt;In the first example the full signature was in the clipboard. In the second example, a shortened version of the method signature was in the clipboard. In this latter example the method argument names are automagically calculated.&lt;/p&gt;

&lt;p&gt;In the first example, the &#8216;.m&#8217; snippet will generate a method invocation version of the signature.&lt;/p&gt;

&lt;p&gt;In all examples, the arguments are tab stops to make it easy to rename arguments.&lt;/p&gt;

&lt;p&gt;&lt;a href='http://github.com/drnic/macruby-tmbundle'&gt;Get the latest MacRuby.tmbundle via git&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Running MacRuby inside TextMate</title>
   <link href="http://drnic.github.com/macruby-tmbundle/2008/12/19/running-macruby-inside-textmate.html"/>
   <updated>2008-12-19T00:00:00-08:00</updated>
   <id>http://drnic.github.com/macruby-tmbundle/2008/12/19/running-macruby-inside-textmate</id>
   <content type="html">&lt;p&gt;In normal Ruby files, Cmd+R will run the ruby script and output any STDOUT to an HTML-based window. If the file is a MacRuby script, then we want it to run through &lt;code&gt;macruby&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;My initial attempt was to clone over the Ruby.tmbundle&#8217;s Run command, and all its Support files, change &lt;code&gt;$TM_RUBY&lt;/code&gt; from &lt;code&gt;ruby&lt;/code&gt; to &lt;code&gt;macruby&lt;/code&gt; and watch awesomeness unfold.&lt;/p&gt;

&lt;p&gt;Unfortunately, awesomeness had to wait. The ruby files had some ruby 1.9 incompatibilities. So I fixed those (no more $KCODE, etc). Then big challenges were discovered. There are ruby 1.9 incompatibilities, and perhaps macruby incompatibilities within TextMate&#8217;s own Support folder.&lt;/p&gt;

&lt;p&gt;My initial attempt to start fixing them has been to pull in TextMate&#8217;s own Support folder into this bundle as a SharedSupport folder. We can now hack away at it and attempt to get this working.&lt;/p&gt;

&lt;p&gt;I found an issue with osx/plist.bundle. On my local machine I pulled down the plist.bundle source which apparently has a ruby 1.9 fix in it, rebuilt it and added it back into the bundle. But it still fails. In fact, the plist.bundle src&#8217;s own tests are currently failing for ruby1.9 and macruby.&lt;/p&gt;

&lt;p&gt;Then there are some issues with io.rb and process.rb I think. These are some dark, mysterious areas of Ruby behaviour that I am merely a happy user of, rather than an intrepid explorer.&lt;/p&gt;

&lt;p&gt;So MacRuby runtime support within TextMate had a short, disappointing burst of life. If you are able to poke around and fix a few bugs, please try running the &#8220;Run&#8221; and &#8220;Run Rake Task&#8221; commands, observer the failure and see what you can do.&lt;/p&gt;</content>
 </entry>
 
 
</feed>