InquiryLabs

Politics, Programming and Possibilities

Archive for February, 2006

Need to Upgrade Rake for Edge Rails

For anyone not following the discussion on the rails dev mailing list, you’ll need to upgrade to Rake 0.7.0 to use any of the standard ‘rake’ commands from now on. An error message that you might get without upgrading, for example, would be:

[duane@mail1 socialconference]$ rake -T
  (in /home/www/socialconference)
  rake aborted!
  undefined method `namespace’ for main:Object
  ./Rakefile:10

So go on and ’sudo gem update rake’ or whatever it is you do to upgrade your gems under your environment and get those namespaces in to rake!

More Fixes and Some Forgotten Files

I meant to include Sami Samhuri’s Snippets and Macros in the last release—and, unfortunately, did so in a half-baked manner. In this release, the snippets and macros are all there, and they sure are cool! Thanks, Sami.

Enter Key Deprecated

Some people asked about the enter key that was bound to the Intelligent Go To File command. Please note that the enter key will no longer be bound to this command by default. See my earlier post for more information on why this key was split in to two commands. Use ⌘⌥↓, bound to the “Go To File” command and ⌘⌥↑, bound to the “Go To File on Current Line” command instead. I’ve included the older (combined) Intelligent Go To File command in the library, but this time I’ve not bound it to any keys.

Download

As usual, please let me know if you find anything amiss.


Download the Disk Image
TextMate Rails Bundle 1.0 RC4

Rails Bundle for TextMate 1.0 RC3

New Way of Accessing Ruby

My friends on IRC have helped me track down and understand better the way TextMate helps its bundles by setting up the environment for Ruby code. The Rails bundle now uses the TM_RUBY environment variable to determine which ruby on your system to use (i.e. if you have multiple ruby shell commands installed).

One of the biggest problems with this environment stuff has been trying to figure out the best way to support all of the many ways you can get Ruby on your system: the built-in version patched with fixrbconfig, DarwinPorts, your own version, or perhaps even Locomotive’s ruby-in-a-box. For those of you who’ve been experiencing problems with past versions of the Rails bundle, I think this one may fix it for you. If you’re still having problems, try adding a TM_RUBY environment variable to your TextMate shell variables (in Preferences, go to Advanced, then Shell Variables). Point TM_RUBY to the location you installed ruby at.

As usual, please feel free to contact me and we can try to work out a solution if you’re still having trouble. Comments showing your problems or solutions are also welcome.

Download


Download the Disk Image
TextMate Rails Bundle 1.0 RC3

Rails Bundle for TextMate 1.0 RC2

Changes

Looks like RC1 didn’t get some of the updated textmate_footnotes plugin code. This release candidate includes the newest testmate_footnotes, and also attempts to fix some issues people have been experiencing with ‘command not found’ and other PATH-related problems. Let me know if we’re getting any closer for those of you having these issues.

UPDATE: Looks like I’m still learning a few things. The folks on IRC tell me that adding the .profile is a very bad thing, so I’m going to have to try to solve this in another way. Download and try if you’d like, but wait for another release if you’re paranoid :)

Download


Download the Disk Image
TextMate Rails Bundle 1.0 RC2

It’s official, folks!

After talking with my partner, Greg Narain, as well as Allan Odgaard, the creator of TextMate, we (syncPEOPLE) have decided to release our Rails bundle under the MIT license so that it can nest itself nicely within its new home, the TextMate Subversion Bundle Repository. If you have subversion set up with TextMate, update your bundles and you’ll get it all.

What this means for the rest of us is that all of these great features we’ve been madly developing are going to be available as the default Rails bundle when the next version of TextMate is released. Thanks to all who’ve contributed to this work already. Keep it up!

Changes in the 1.0 Release Candidate

There are some major key binding changes in this release, due to my own slow but steady understanding of TextMate conventions and the evolving complexity of making this intuitive. Bundle keys are normally bound to the ctrl-shift combination, not the command-option combination. Therefore, in following with this convention, the new bundle uses the following bindings for its commands:

  • ⌘⌥↓: Intelligent Go To File
  • ⌘⌥⇧↓: Show “Go To File” Choices
  • ⌘⌥↑: Go To File on Current Line
  • ⌃⇧” (without selected text): Inline Partial Edit Mode
  • ⌃⇧” (with selected text): Create Partial from Selection
  • ⌃⇧\: Call Generator Script
  • ⌃⇧\: Install Plugin

The Enhanced TODO List has been moved to the TODO bundle itself, so everyone (Rails and non-Rails folks alike) will benefit from it. It will be updated soon.

New Language Scoping

In order to create the “Show Go To File Choices” command and its list of choices, I created some new language scoping rules in TextMate that may prove interesting in the future. Basically, there are 6 new scopes available for Rails bundle creators to play with:

  • meta.rails.functional_test
  • meta.rails.controller
  • meta.rails.helper
  • meta.rails.mailer
  • meta.rails.model
  • meta.rails.unit_test

What this amounts to is that you can bind certain snippets, commands or macros to specific scopes within the rails project. For example, suppose you want to create a macro that adds scaffolding code to your controller. With the new scopes, you can bind your command to meta.rails.controller and rest assured that you won’t accidentally add scaffold actions to your model. In addition, this new scoping allows you to bind multiple commands with the same key binding to a single scope to create a pop-up menu with choices. Try ⌘⌥⇧↓ to see this latter benefit in action.

What About the ‘Keypad Enter’ Key Binding?

After some discussion, we (Allan and I) decided to remove the keypad enter binding and replace it with the ⌘⌥↓ key combination. There were a number of reasons for doing this:

  • ⌘⌥↓ has been bound to a similar function, rails-open-partner, for some time already.
  • The keypad enter key doesn’t work on PowerBooks and iBooks without some tweaking.
  • The keypad enter key is already bound to a global next-line action.

With that said, however, there’s certainly nothing stopping you from re-binding the enter key to your Rails bundle. If it works for you that way, great!

Final Words

I’ve put a lot of work in to making this release a much more robust, refactored release. There are some really handy classes that have been created just for TextMate (included in the bundle) that I’d like to mention for the benefit of other bundle makers:

  1. TextMate Module: Namespace module for message functions, opening text files in textmate, and exiting with special exit codes that TextMate understands.
  2. Buffer Class: Reads in a text file and provides search functionality as well as state information (such as current line and current column number).
  3. RailsPath Class: Understands the Rails app directory structure and provides a way to easily swap between associated files. For example, calling rails_path_for(type) on a controller file will pass back the full path (wrapped in a RailsPath object) of any associated helper file or functional test file.
  4. UnobtrusiveLogger Class: Use $logger.debug “(your message here)” to send output to ~/textmate_bundle.log.
  5. String Class Modifications: See misc.rb for mods to String

Get it now!

If you don’t use the subversion repository, download the new Rails bundle as a Disk Image here.


Download the Disk Image
TextMate Rails Bundle 1.0 RC1

I did a presentation at our local Utah Ruby Users Group tonight on the motivation and application of the bundled_resource plugin.

You can download the slides in Microsoft PowerPoint format or view the slides as an html presentation.

Thanks to everyone who showed up to participate tonight!

Kudos to Allan Odgaard the creator of TextMate for building such a powerful and flexible editor for the Mac. Without his brilliant work, making these 4 releases in 3 days would certainly not have been possible.

I’d also like to thank the several contributors who have worked with me to improve this Rails bundle in so short a time: Sami Samhuri for his Snippets contributions, Cliff Matthews for his patches for the Intelligent Go To File command, Kent Siblev for fixing a CocoaDialog issue and Pete Lasko (my coworker and partner) for many of his bright ideas.

How About Those Routes?

Tim Lucas proposed an interesting challenge in his comments following the 0.7 Release:

…and now for the ultimate challenge: recognise a URL through an app’s route configuration and take you to the relevant action. Combine this with a bookmarklet and you could go from any web page straight to the relevant controller action.

My initial reaction to his idea was, “That’d be cool, but forget it right now. Maybe in the 2.0 release .” Way too much work for a bundle, it seemed. But then another approach bubbled up from a conversation between me and Pete Lasko. Why not add footnootes to each page that link you to the appropriate action or view? Why not indeed. This is very similar to the calling and purpose of the textmate_backtracer plugin—but instead of showing links to just error pages, show links to each and every page while in development mode on the Mac. From thence was born the textmate_footnotes plugin, now included in syncPEOPLE on Rails 0.9.

Oh yeah, and as a bonus, textmate_footnotes includes all of the functionality of the textmate_backtracer, thus deprecating the backtracer.

Wait, Did You Say the Plugin is Included in the Bundle?

Well, yes, actually. As part of this release, we’ve included a novel “plugin installer” from within TextMate. Hit ctrl-command-option-\ and you will be given a choice of plugins to install from the syncPEOPLE on Rails Bundle to your active Rails application. Currently the Rails Engines and the textmate_footnotes plugins are available as options.

For the adventuresome among you (yes, that’s just about all of you) you can add any plugins you’d like to the tmbundle/Support/plugins directory and they will be automatically included in the drop-down select box when you invoke the plugin installer. In future releases, we may have a way for you to “tag” external plugins or repositories to automatically download and install them as options.

Some New Snippets from Sami

Also included in this release are a number of snippets that make migration files a little easier to build. Documentation is included in the Disk Image download.

Get it now!

Without a doubt, this bundle is becoming the essential resource for Rails developers on TextMate. Jamis Buck and Tobias Luetke on the Rails core team have downloaded and installed it—perhaps we’ll soon hear some reviews from them and others.


Download the Disk Image
syncPEOPLE on Rails 0.9.1

syncPeople on Rails 0.8

Suggestions and features just keep bursting from everywhere.

Summary of Release

In this release, we’ve added Inline Partial Editing, bound to the same command as the Create Partial from Selection feature (command-option-p). Now you can edit your partials inline and save them out again to their appropriate files. Thanks to Kyle Maxwell for the suggestion.

There’s also an experimental “generate” command that will generate scaffolding, controllers, models and more right from within TextMate. Bound to command-option-g by default.

Details

  • keypad ‘enter’: Intelligent Go To File

    Works in many different contexts. Checks the current line first to see if there are any “render”, “redirect_to” statements or javascript / stylesheet files. Goes to the file if found. Otherwise, if you’re inside a controller’s action, it will take you to the view. If you’re inside a view, it will take you to the corresponding controller action. Also works for ActionMailer models with their corresponding views.

  • command-option-p (with selection): Create Partial from Selection

    When inside a view file, select some HTML or erb code that you would like to turn in to a partial. Hit ‘command-option-p’ and a dialog asking you for the name of your new partial will pop up. Name your partial and hit ‘ok’. The selected text will be replaced by a “render :partial” erb fragment and the text will be saved in the newly named partial file.

  • command-option-p (without selection): Inline Partial Edit Mode

    When inside a view file that contains one or more “render :partial” statements, hit “command-option-p” without any selection and your partials will be brought in to the current file to be edited. Once done with them, hit command-option-p again and they will be saved to their appropriate locations and removed.

  • command-option-g: Rails Generator

    Hit ‘command-option-g’ from any file and you will be taken through 2 or 3 simple dialogs to help you generate scaffolds, models, migrations, controllers and more.

  • ctrl-shift-t: Enhanced TODO List

    Lists all mentions of TODO, CHANGED, and FIXME within your project. Lets you toggle the three categories on and off.


Download the syncPeople on Rails 0.8 Disk Image

I’m not sure if this is all black magic or what, but the process seems to be pretty undocumented around the ‘net. I’d like to make a nice drag-n-drop installer for the new syncPeople on Rails Bundle. Something with a nice background image, and an internet-enabled bit so it opens right up in Safari.

So far, the only two good links I’ve found to creating a Disk Image with a picture background are:

Still looking for that ultimate “Free, Instantaneous and Perfect” product…

"syncPeople on Rails" 0.7

Isn’t it great when you find some time to work on a project you’ve been meaning to do for a while?

Following the 0.5 release and the 0.6 release, the “syncPeople on Rails” TextMate bundle has reached version 0.7. Here are the feature updates:

New Features

  • Includes an Enhanced TODO List from Niko Dittman — ctrl-shift-t
  • The Intelligent Go To File command now understands 6 new contexts — keypad ‘enter’ key
  • Now released under the LGPL license
  • Enhanced TODO List

    This was a gem I picked up from the TextMate mailing list that we’ll be using at syncPeople. Basically it gathers all of your TODO, FIXME, and CHANGED messages from all of your project files and color codes them in a nicely formatted HTML window. In addition, you can turn any of the categories on and off if you need to focus on one aspect or the other in your work flow. Replaces the old TODO list with ctrl-shift-t.

    Note: You may have to turn off the old TODO list key combo in your commands.

    New Intelligent Go To File Contexts

    Hitting the ‘enter’ key is even smarter: it will now visit javascript and stylesheet files. For example, clicking on any of the following formats will take you to the javascript or stylesheet: