Skip to content

Instantly share code, notes, and snippets.

@dev4dev dev4dev/deploy.rb
Created Feb 4, 2013

Embed
What would you like to do?
Builder auto deploy script
#!/usr/bin/env ruby -wKU
# encoding: UTF-8
def fail message
puts "ERROR: " + message
exit(-1)
end
def log message
stars = '*' * (message.length + 6)
puts "\n"
puts stars
puts '* ' + message + ' *'
puts stars + "\n"
end
def install_brew
puts 'Installing Homebrew...'
system %Q[ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"] or fail 'Brew installation failed'
system %Q[brew doctor]
end
def install_rvm_ruby_reqs
puts 'RVM requirements...'
system %Q[brew tap homebrew/dupes]
system %Q[brew install bash curl git]
puts 'Ruby requirements...'
system %Q[brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba]
end
def install_rvm_ruby
puts 'Installing RVM and Ruby...'
system %Q[curl -L https://get.rvm.io | bash -s stable --ruby] or fail 'RVM & Ruby Installation failed'
end
# Homebrew
log 'Homebrew...'
brew_check = File.exists? '/usr/local/bin/brew'
if brew_check
puts "You have #{`brew -v`}"
else
install_brew
puts "Brew done.\n"
end
# RVM && Ruby
log 'RVM & Ruby'
rvm_check = File.exists? File.expand_path('~/.rvm/bin/rvm')
if rvm_check
puts "You have #{`rvm -v`}"
else
install_rvm_ruby_reqs
install_rvm_ruby
puts "RVM & Ruby done.\n"
end
# check Ruby
ruby_check = `which ruby`
if ruby_check
puts "You have #{`ruby -v`}"
else
system %Q[rvm install ruby] or fail 'Ruby installation failed'
end
# builder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.