#!/usr/bin/env ruby
require 'fileutils'
# switches to vendor/rails and pulls rails, and shows you the commit
pull = ''
FileUtils.cd('vendor/rails', :verbose => true) do |foo|
puts "Pulling Rails"
pull = %x{git pull origin master 2> /dev/null}
puts pull
git_commit = ''
File.open('.git/refs/heads/master', 'r') do |file|
git_commit = file.read
end
puts "Rails Commit: #{git_commit}"
end
# Tells you the ruby you're using
version = ""
if %x{ruby -v} =~ /\w ([\d\.]+) (.*)/i
version = $1
puts "Using Ruby: #{version}"
end
# if pull is not up to date, bundles the gems again.
unless pull =~ Regexp.new("Already up-to-date")
FileUtils.rm_rf('vendor/gems', :verbose => true)
puts %x{rvm use 1.9.1}
puts %x{gem bundle}
puts %x{rvm use 1.8.7}
puts %x{gem bundle}
puts %x{rvm use #{version}}
end