Brad's Musings http://blog.bradgessler.com A Smörgåsbord of gray gooey stuff from my brain posterous.com Thu, 27 Aug 2009 20:23:00 -0700 Ruby DSL Trick with the Hash http://blog.bradgessler.com/ruby-dsl-trick-with-the-hash http://blog.bradgessler.com/ruby-dsl-trick-with-the-hash

Today I had to rig up a method for defining symlinks in Capistrano. I never really liked how the ln command worked to begin with; I think of symlinks in terms of:

Alias A targets File B

To make this easier I wrote up this method:

def link(link)   source, target = link.keys.first, link.values.first   run "ln -nfs #{target} #{source}" end

Which reads as:

link "alias_a" => "file_b"

I love finding these little ways that make my code more readable.

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/32100/bgessler.png http://posterous.com/people/2JKWmnyY Brad Gessler Brad Brad Gessler