Source_Checkout.rb

The following script runs through each url you've set and pulls down the source for it. I use it for installing merb & datamapper onto a new server because they require an svn checkout and a few git clones and I'm lazy :)

Tested On

#!/usr/bin/env ruby
# 
#  source_checkout.rb
#  Checks out the source repositories defined
# 
# Only works for subversion (svn), mercurial (hg)
# and git (git) for now.
#  
#  Created by Caius Durling on 2008-02-09.
#  Released into the Public Domain, read the code
#  through and don't blame me if it runs away
#  with your wife!'
# 
 
# Setup the repos to pull from
# Example
  # :folder_name => {
  #   :url => "url to repo",
  #   # Specify the scm if you want, I'll attempt to 
  #   # work it out if you don't
  #   :scm => "svn"
  # }  
"http://datamapper.rubyforge.org/svn/trunk",
    :scm => "svn""git://github.com/wycats/merb-core.git""git://github.com/wycats/merb-more.git""git://github.com/wycats/merb-plugins.git"# Attempt to figure out the scm from the url
""# Return the correct command for checking out
"svn""svn checkout"
    # Nifty trick
"hg""git""#{self} clone"# Loop through them and check them out
"Checking out the #{name} repo"
 
  # Get the scm name
# Sanitise scm
  # "Common Name" => "command"
  {
    "subversion" => "svn",
    "trunk" => "svn",
    "mercurial" => "hg"#{key}/i, "#{val}")
# export PATH=":/opt/local/bin"; # For OS X
    #{scm.command} #{arr[:url].to_s} #{name.to_s}
"#{name} repo was successfully checked out"Example 1 -- ruby snippet -- Select Code