how do I write a homebrew recipe? What are the key features of a homebrew recipe? 

If I want to contribute a recipe, e.g. this one for udunits to the the hombrew-science repository, how would I convert a command-line script like this:

wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.1.24.tar.gz
tar -xvf udunits-2.1.24.tar.gz
cd udunits-2.1.24
./configure 
make 
make check
make clean


into a valid recipe?
This Homebrew README gives these steps (with links to more information):


  Contributing
  
  In short:
  
  
  Fork Homebrew.
  brew create http://example.com/foo-0.1.tar.gz
  git checkout -b foo
  git commit Library/Formula/foo.rb &amp;&amp; git push
  Pull Request.
  
  
  In long:
  
  
  Formula Cookbook
  Acceptable Formulae
  


Homebrew formulas are written in Ruby (tested against Ruby 2.0.0). Knowledge of Ruby certainly helps, but you might be able to get a feel for how to do basic procedures like you outline above just by reading a few existing formulae.

Getting a formula accepted also requires a little knowledge of Git and GitHub pull requests, but is covered How to open a Homebrew pull request (and get it merged)