Get ready for the TextMate “Trundle to Rails 2.0 Bundle”

Posted by Dr Nic on January 31, 2008

logo_bundle.png

Have you noticed lately that the Rails TextMate git pull origin two_point_oohbundle (also installed with e - the Text Editor for Windows) isn’t quite as helpful as it once was - guiding and amplifying your rails app development.

Your resourceful/restful rails apps are now filled with named routes, but none of the helpers (link_to, redirect_to, etc) use them. The default view template was still rhtml for a long time (latest svn trunk fixes this to be html.erb, though Marc Jeanson is having a crack at supporting both through a per-project config file).

Or perhaps you were hoping for some snippets for new features of Rails 2.0: assert_difference (asd), assert_select (ass), respond_to (rst).

Or just maybe, you’ve been updating your local bundle to Rails 2.0 already? Please say yes, please say yes. If you are saying “yes”, read at the bottom for how/where to send me the patches. If you are saying “no”, read at the bottom for how/where to start creating patches and sending them to me.

Firstly, DHH didn’t write the Rails bundle

I didn’t know this - I just assumed the guy who created Rails and helped promote TextMate also created the Ruby on Rails TextMate bundle. Instead if was WWF’s “The Rock” himself Duane Johnson (figurines sold separately, and may look different to the real Duane Johnson who writes Rails code instead of prancing around in his underpants with other adult males in confined spaces).

The TextMate SVN logs say that it the bundle was first committed in Jan 2005. Its now Jan 2008. That’s three years of maintaining a suite of code that thousands of people take for granted every day writing Rails code. What a champion.

Like the Australian Cricket team’s wicketkeeper, Adam Gilchrist, he’s also retiring at the top of his game.

New Maintainer… me

Instead of maintaining my own projects, I’ve decided to maintain this one. I love the TextMate bundles. Before I had a Mac, I ported them across to RadRails and many RadRailers entered a golden era of snippet happiness.

My bundle-fu may not be the equivalent of Bruce Lee, but I’m keen to see my favourite Rails tool live on strong.

Bleeding edge bundle

Whilst the TextMate SVN administrators process the maintainer change request (Allan is on holidays somewhere and he took the house keys with him), you might think all is lost!

Never.

The straight-off-the-cow bleeding edge Rails bundle can be accessed via Git. Specifically the branch two_point_ooh.

So, let’s all do away with our pre-existing Rails bundle and live on the edge.

cd ~/"Library/Application Support/TextMate/Bundles/"
mv "Ruby on Rails.tmbundle" "RoR.tmbundle.orig"
git clone git://github.com/drnic/ruby-on-rails-tmbundle.git "Ruby on Rails.tmbundle"
cd "Ruby on Rails.tmbundle"
git checkout --track -b two_point_ooh origin/two_point_ooh
git pull

Now, back in TextMate, go to menu “Bundles” > “Bundle Editor” > “Reload Bundles”.

You, my friend, are sitting pretty.

Upgrading to when newer blood is on the bleeding edge

Coming back for more?

cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git checkout two_point_ooh  # optional; only if you changed to another branch etc
git pull

Now, back in TextMate, go to menu “Bundles” > “Bundle Editor” > “Reload Bundles”.

Bathe yourself in glory. Splash it all over yourself.

Submitting patches

If you go into TextMate, launch the Bundle Editor (Cmd+Alt+Ctrl+B) and change something in the Ruby on Rails bundle, then files will added/changed within your local git clone.

What I mean is, you can very simply submit patches now. [When I say "simply", I mean, "I think this is the best approach but I could be completely wrong here..."] Git is so cool that I don’t know what its doing most of the time; but let’s hang in there as a team.

cd ~/"Library/Application Support/TextMate/Bundles/Ruby on Rails.tmbundle"
git add .   # to add any new files/snippets/commands you created; TextMate uses one file per snippet
git commit -a -m "Useful message about this patch goes here"
git diff -p HEAD^ HEAD

[Theoretically] this creates a patch based on your most recent commit. So you can easily create patches for changes even if your repository and the remote/central/bleeding edge repository look different.

If your patch was created over several commits, then replace HEAD^ with HEAD~4, if there were 4 commits.

I think. God I could be wrong about this though.

Just try your best and if it works, let me know and I’ll remove all this “I don’t know what I’m talking about” text and future readers will think I know everything. Web 2.0 rocks.

Send patches to…

Me drnicwilliams@gmail.com [update] or via the new Google Group.

Want to fork the git repo? Use a free account at Gitorious or GitHub.

Google Groups
Ruby on Rails: TextMate
Visit this group

Trundle to Rails 2.0 Bundle

Arguably, we just keep patching the bundle forever and bleeding edges will continue to live happily within the blood and muck of said existence.

But, lots of other people want nicely zipped up bundles. No doubt “e - the Text Editor” will want a “released” version so they can clean it of all the ugly things they can’t yet replicate like Macros. And eventually I’ll push it all down to the SVN repo and it will be released with future TextMate upgrades.

So, there will be a “Rails 2.0 compatible” grand opening one day soon. Probably before 14th of March 2008, when I’m giving a “What’s new in Rails 2.0?” talk at QCON London. Showing off the new bundle will be sweet.

That gives us 6 wks to refactor this bundle to make it a shining example of all that is wonderful in Rails 2.0. Every patch helps.

[Please consider Rails 1.2.6 and before developers when conceiving of patches, and please consult your doctor if pain persists.]

Magic Wiggly Lines => GuessMethod, by Chris Shea

Posted by Dr Nic on July 23, 2007

If you ever make time to code just for pleasure, then method_missing and const_missing are just begging for abuse.

Chris Shea has come up with GuessMethod - a very cool hack that now deprecates my concept of Magic Wiggly Lines - a spell-checker for runtime code.

What’s it do? Cop a squiz at this genius…

$ gem install guessmethod -y
$ irb
> require 'rubygems'
> require 'guessmethod'
> class Object; include GuessMethod; end  # though this could go in the guessmethod.rb file in the gem
> class Product; def name; "Some product"; end; end
> Prodct.nw.nae
attention: replacing non-existant constant Prodct with Product for Object
attention: sending new instead of nw to Product:Class
attention: sending name instead of nae to #<Product:0×144ff10>:Product
=> “Some product”

That’s going straight into my .irbrc file. My bad spelling, coupled with my British/Australian English, will never slow me down again!

UPDATE: actually, it doesn’t like being in the .irbrc file for Rails console; so in the config/environments/development.rb files will have to do for the moment.

OpenID for Wordpress

Posted by Dr Nic on July 03, 2007

This blog - nay, this InterTubes HomePage - runs on Wordpress.

This website allows you to comment. Like a blog. Let’s call it a blog. That’s shorter than “website”.

To comment you’ve got to fill in your name and email and website every… single… time…

Well, I don’t have to, because I have an account.

So I completely forgot about everyone else’s plight. That is, until one young soldier Rodney Ramdas, ask a good question:

hey is there an openid enabled commenting thingy [for your blog]?

OpenId logo

So I found OpenId plugin for Wordpress.

Now you can create an account on my site using OpenID and never have to fill all that crap in again.

UPDATE: See comments below for how to use your blog domain name/url as your OpenID url. As it is this url that is appearing below people’s names, and that’s not what you want. That is, I can use drnicwilliams.com as my OpenID, even though it is actually http://drnicwilliams.myopenid.com/.

You can check that you’ve setup up your blog as your OpenID with this helper site.

Functional Testing using a Matrix to cover all edge cases [video]

Posted by Dr Nic on May 22, 2007

I’ve been a fan of Ryan Davis‘ (zenspider) and Eric Hodel‘ ZenTest library (including its autotest CI tool for rails and gems), and their Hoe gem, the Rubyforge gem, etc ever since I figured out what they did. (Side note: how to setup rubyforge gem)

Over the last month, Ryan mentioned “functional testing by a matrix” in four great blog articles.

Ryan shows this off at RejectConf; its 16 minutes but definitely worth your time to investigate, as I think this will be awesome for ensuring basic edge cases are thoroughly tested. Can a guest create something? Can a member delete something?

It is hard to see the code on the screen, but look at the blog posts linked above to get the gist of what is being shown.

People were really interested this as you can tell by the huge number of questions, despite this being the last of many many presentations.

This stuff looks primed for a sweet generator to create the test file.

Railsconf => 4 tracks; JavaOne => simultaneous 14 tracks!!

Posted by Dr Nic on April 27, 2007

MyConfPlan now includes all the sessions for next month’s JavaOne conference. It is huge! 400+ sessions, with up to 14 simultaneous sessions.

I’m going to JavaOne 2007

Remember to go see Charles Nutter’s JRuby session.