Dr Nic

Validate and Save your Ruby in TextMate – with secret Rubinus superpowers

In some TextMate bundles, if you save a file it will also validate the file and show any syntax errors in a tooltip. This is awesome. (e.g. JavaScript and CoffeeScript)

So I added the same thing to my Ruby.tmbundle. Install this, save a dodgy Ruby file and you’ll now see something like:

Validate and Save - No Rubinius

Rubinius superpowers

Do you think the following syntax error tooltip is more useful?

Validate and Save - Rubinius installed

Yes it lovely, and the new Ruby.tmbundle will automatically do this if it can find rbx in your TextMate’s $PATH. Yeah yeah.

If you have Homebrew installed:

brew install rubinius

Then in TextMate, add your homebrew bin folder to the $PATH.

  • Go to TextMate’s Preferences (Cmd+,)
  • Go to “Advanced”, then “Shell Variables”
  • Edit the PATH variable, and add “:/path/to/homebrew/bin”

For example, if you have homebrew installed in ~/.homebrew then you might add :/Users/drnic/.homebrew/bin

. My complete $PATH in TextMate is:

/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin/:/Users/drnic/.homebrew/bin

Save a dodgy Ruby file and see the beautifully helpful syntax message.

Install Ruby.tmbundle

To install via Git:

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/drnic/ruby-tmbundle.git "Ruby.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'

Related posts:

  1. Trialing RedCar instead of TextMate – replacing my aliases I’m interested to trial RedCar in my life, instead of...
  2. Packaging TextMate bundles in OS X DMGs Last week Engine Yard released a CLI for their Engine...
  3. Future proofing your Ruby code. Ruby 1.9.1 is coming. Bugger. I’m a Ruby monogamist. I use the Ruby...
  4. TextMate easter egg: find bundle commands by key combo I’ve dreamed of the ability to ask TextMate “what frigging...
  5. My attempt at sake task management I’ve used sake intermittently in my workflow. It competes...

5 Responses to “Validate and Save your Ruby in TextMate – with secret Rubinus superpowers”

  1. [...] This post was mentioned on Twitter by Dr Nic, Łukasz Strzałkowski. Łukasz Strzałkowski said: RT @drnic: Ruby.tmbundle will now automatically "Validate & Save" on Cmd+S and uses Rubinius superpowers if installed http://bit.ly/ceocfr [...]

  2. Nic,

    Is there a way to turn this off? I’ve updated to the latest bundles and it shows errors on a lot of our partials. A simple test case is test_case = 1 inside ERB escape strings.

    George

  3. Dr Nic says:

    @George – critical bug now fixed. Sorry about that.

  4. sokak trendi says:

    Dr.Nic thanks a lot for fixing bug. I didn’t want to write when Mr. George post about bug.

  5. Konstantin Haase says:

    One thing that would be super awesome: Make it work with rvm out of the box (symlinking sucks, as you have to keep track what and where the current version is).