« July 2007 | Main | October 2007 »

August 2007

August 30, 2007

Superators: neat Ruby hack

Superators
Image stolen from jicksta.com


So, I'm not sure if Jay Phillips (of Adhearsion fame) is trying to annoy the purists with a remarkably Perlish hack in Ruby. I just know that his superators gem is a clever bit of pure Ruby code that allows you to apparently define new infix operators in Ruby programs. Imagine the joy of being able to write


a /~ b

and

rocket <=- fuel

You can with superators:


require 'rubygems'
require 'superators'

class String
superator "<=-" do |arg|
self << arg.upcase
end
end

Is this a good idea? I don't know. I can see that it would have been useful in some DSLs that I've written. But I do think that it's a wonderfully clever implementation (it doesn't do anything nasty to the interpreter–it simply intercepts built-in operators (such as <<= and -) in my example above. And that's what makes it great. Every now and then, just when you think you know Ruby. someone comes up with something—such as symbol.to_proc or superators—that makes you go "oh!."

Every long-lasting relationship needs the occasional surprise to keep it interesting and fun. This kind of hack is one of the reasons I love Ruby.

August 21, 2007

Deploying Rails Applications

There's always been something of a discontinuity when it comes to creating a Rails site. The Rails framework makes writing the applications themselves a lot easier than any other common framework. The sensible defaults and conventions combine to create code that somehow just works. You race through the development phase, giddy with the speed with which you implement each feature.

Fr_deploy

Then you reach the part where you have to deploy your application, and you find yourself with two black eyes, brought on by the rapid deceleration that takes place. Suddenly you've gone from the hyper-productive world of Rails coding to the traditional world of web application deployment. We're back talking about web server configuration, monitoring daemons, clustering, and so on. Then, to make it even more interesting, the Rails world seems to switch preferences for server-side technologies almost monthly: Apache, lighttpd, mongrel, and now nginx all compete for your attention.

That's why I was really keen to get a great book on deploying Rails applications out the door. Ezra Zygmuntowicz and Bruce Tate have obliged. Deploying Rails Applications is now out in beta. As a founder of Engine Yard, Ezra is one of the most experienced people in the world when it comes to Rails deployment. As the author of nine books (including From Java to Ruby, Bruce brings a wonderful writing style to the book.

They're not finished yet, and I understand that they'll be updating some of the existing content (for example to cover the new Capistrano 2). If you're deploying a Rails application, I recommend checking it out.

August 13, 2007

Possibly my favorite Rake target

rake gerbils:deploy


Cry "Havoc!" and let slip the rodents of PDF generation.

Now in Beta

  • Programming Ruby, 3rd Edition
    Third Edition, Covering Ruby 1.9, now in beta
My Photo

Site Search

  • Google Search

    The web
    PragDave

Pragmatic Stuff

Photos

  • www.flickr.com
    This is a Flickr badge showing public photos from pragdave tagged with pragdave_badge. Make your own badge here.