Check out this excellent book (I highly recommend it):

"Code Generation in Action" ( http://www.manning.com/herrington/ )

And what's more interesting, is that the author, after deliberating on 
various alternatives (Perl, Java, Python, etc), chose Ruby as the 
language for code generation.

Looks like Ruby is slowly but surely bubbling up to the top!

QXX