Accessing FastRI from TextMate

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:

TextMate FastRI command
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 (a.k.a. MFP) for all his work on FastRI!