Thursday, September 4, 2008

A script to help with Rails -> Merb conversions

People have asked often in #merb for something to help with converting Rails apps to Merb apps. There's no magic Wizard to do this for you, but hopefully this will help:

http://github.com/jackdempsey/find_rails/tree/master

Its a standalone Thor script that looks in your current directory (or a provided path to an app), finds the app/ directory, and scans through the code for a variety of things that people get tripped up on in Merb. I imagine this list will increase over time, but it will help with some of the obvious ones to start.

This is very much a work in progress. Running it standalone like this, especially given the way I've organized it, loses some of the flexibility Thor provides. It also makes it easier on the user to invoke. I imagine if this is used by people and grows to be anything bigger than a simple helper script, I'll refactor the way the task is started, so I'd recommend cloning this and playing with the source a bit as well.

Anyway, if you haven't played with Thor yet, you should give it a go. Its fast, flexible, and a great way to avoid the "fun" of parsing options yourself.

Currently there's a bit of an issue with installing tasks that have multilevel namespaces. For the time being, I've committed a fix to the constants branch of my fork at http://github.com/jackdempsey/thor/tree/constants

I foresee this fix getting cleaned up and merged into the main Thor repo soon. In the meantime, if you're looking at using Thor with tasks like foo:bar:baz, this fork will fix things up for you.

Update

I fixed things up a bit so that we can search on regex's as well. This came out of a discussion in #merb re: the tendency to "redirect && return" in Rails, which is the reverse of what you'll want to do in Merb.

http://github.com/jackdempsey/find_rails/commit/ea80df077c8cee0959ce1e7b4b17321924f19dc7

2 comments:

Anonymous said...

You are a retard

Anonymous said...

can you make a Thor script to explain why you'd even want to convert a functioning Rails app to Merb or would it only output l33tspeak and lolcats?