Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

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

Saturday, August 30, 2008

Experimenting with Ubiquity

For those of you who know what Ubiquity is, I'll keep this brief. For the non-initiated, take a second to read about what many describe as Quicksilver for Firefox: http://labs.mozilla.com/2008/08/introducing-ubiquity/

You can install it here, read the tutorial and then come back when up to speed.

Cool stuff, right? So I took a look at their wiki earlier and was kind of surprised to find that nothing was listed there for Ruby...but you could search for php functions? Blasphemy...so I took their code and hacked it up a bit:



Easiest way to play with this in my opinion is, once you've installed Ubiquity, test it at chrome://ubiquity/content/editor.html

As you can see from the gist, its pretty easy to create a new command to play with and you can easily add in search capability for your favorite site. If its well known there's a shot someone's done that already.

Anyway, I thought this was pretty cool and imagine over time it will enable some pretty interesting mashups. Its almost a more powerful and approachable version of Yahoo Pipes, albeit a different sort of beast.

As I get time I'll be playing more with it, probably hooking up some nice Merb search capabilities. Feel free to drop some comments if you have some ideas, but perhaps aren't familiar with Javascript or coding in general. Enjoy!

Monday, July 14, 2008

leopard, rubygems, and bus errors

Every now and then I catch one of these errors:
1
2
3
4
5
6
~/git/project_foo $ rake -T
(in /Users/jackdempsey/git/project_foo)
/usr/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.8.4/lib/xml/libxml_so.bundle: [BUG] Bus Error
ruby 1.8.6 (2007-09-24) [i686-darwin9.0.0]

Abort trap



In my experience this just means that you've done some custom stuff to ruby on your Leopard install, and the bundled gems that come with Leopard these days aren't happy. Simple fix, just uninstall the gem and reinstall. This gives things a chance to build the extensions correctly, and be happy from then on:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
~/git/project_foo $ gem list lib

*** LOCAL GEMS ***

libxml-ruby (0.3.8.4)
~/git/project_foo $ sudo gem uninstall libxml-ruby
Successfully uninstalled libxml-ruby-0.3.8.4
~/git/project_foo $ sudo gem install libxml-ruby
Building native extensions. This could take a while...
Successfully installed libxml-ruby-0.7.0
1 gem installed
Installing ri documentation for libxml-ruby-0.7.0...
Installing RDoc documentation for libxml-ruby-0.7.0...
~/git/project_foo $ rake -T


(things show nicely now)