Accessing FastRI from TextMate
February 2nd, 2007
Firstly, you might want to check out the page for FastRI if you haven’t heard of it. It’s Ruby-RI on crack. Tasty crack.
By now, you’ll probably find this little Textmate command useful. All I need to do now is hit ⌃F, type in the class, method, or combination of the two, hit return and I get the Ruby documentation in seconds.
Here’s the little query input window that pops up:

And then the result window:
And now the command itself:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
require_cmd "${TM_FRI:=qri}" "If you have installed FastRI, then you need to either update \
your <tt>PATH</tt> or set the <tt>TM_FRI</tt> shell variable (e.g. in Preferences / Advanced)"
friOutput=`iconv -f utf-8 -t mac <<END|osascript
on run argv
set AppleScript's text item delimiters to {"\n","\r"}
set searchString to ""
tell application "TextMate"
display dialog "FastRI Query:" default answer "" buttons {"Search!"} default button 1
end tell
set searchString to the text returned of the result
set friOutput to do shell script "qri --format plain " & searchString
return friOutput
end run
END`
echo "<html><head /><body><pre>"$friOutput"<pre></body></html>"
exit_show_html |
Huge thanks to Mauricio Fernandez (MFP) for all his work on FastRI!

January 1st, 2008 at 11:01 AM
Hi Nathan, I have quoted this page from your blog to my article. The command worked like a charm! Also you might want to add source.ruby and source.ruby.rails.embedded as the command scope.
the revision 1431 on textmate shows that James have included the fast-ri to ruby-bundle. I supposed to have fast-ri for textmate ready onec I built the index. But the documentation command still shows ri output. Any ideas?
January 14th, 2008 at 11:28 AM
Hi Yudi,
I don’t have access to Textmate right now so I can’t test, but from what I can tell, you’ll need to run
to get your index ready. The key is then the selection of ‘qri’ instead of ‘ri’, which is done in Ruby.tmbundle/Support/bin/linked_ri.rb. Something must be going wrong for you at that point.Hope that helps!