# Rudyfile
#
# This configuration is used to test installing
# and running net-ssh on a clean machine. 
#
# Usage:
#
#     $ rudy -vv startup
#     $ rudy -vv testsuite
#     $ rudy -vv shutdown
#
# Requires: Rudy 0.9 (http://code.google.com/p/rudy/)
#

defaults do
  color true
  environment :test
  role :netssh
end

machines do
  region :'us-east-1' do
    ami 'ami-e348af8a'               # Alestic Debian 5.0, 32-bit (US)
  end
  env :test do
    role :netssh do
      user :root
    end
  end
end

commands do
  allow :apt_get, "apt-get", :y, :q
  allow :gem_install, "/usr/bin/gem", "install", :n, '/usr/bin', :y, :V, "--no-rdoc", "--no-ri"
  allow :gem_sources, "/usr/bin/gem", "sources"
  allow :gem_uninstall, "/usr/bin/gem", "uninstall", :V
  allow :update_rubygems
  allow :rm
end

routines do
  
  testsuite do
    before :sysupdate, :installdeps, :install_gem
    
    remote :root do
      directory_upload 'test', '/tmp/'
      cd '/tmp'
      ruby :I, 'lib/', :I, 'test/', :r, 'rubygems', 'test/test_all.rb'
    end
    
    after :install_rubyforge, :install_github
  end
  
  install_gem do
    before :package_gem
    remote :root do
      disable_safe_mode
      file_upload "pkg/net-ssh-*.gem", "/tmp/"
      gem_install "/tmp/net-ssh-*.gem"
    end
  end
  
  package_gem do
    local do
      rm :r, :f, 'pkg'
      rake 'package'
    end
  end
  
  remove do
    remote :root do
      gem_uninstall 'net-ssh'
    end
  end
  
  installdeps do
    remote :root do
      gem_install "rye", "test-unit", "mocha"
      rye 'authorize-local'
    end
  end
  
  sysupdate do
    remote :root do                  
      apt_get "update"               
      apt_get "install", "build-essential", "git-core"
      apt_get "install", "ruby1.8-dev", "rdoc", "libzlib-ruby", "rubygems"
      mkdir :p, "/var/lib/gems/1.8/bin" # Doesn't get created, but causes Rubygems to fail
      gem_install "builder", "session"
      gem_install 'rubygems-update', "-v=1.3.4"  # circular issue with 1.3.5 and hoe
      update_rubygems
    end
  end
end

