#!/bin/bash

aptitude update
aptitude -y install build-essential git-core zlib1g-dev libssl-dev libreadline6-dev




# rubygems: skip ri and rdoc on production server
echo '---
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
gem: --no-ri --no-rdoc
' >> ~/.gemrc


# rbenv system-wide install
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

echo '# rbenv system-wide install
export RBENV_ROOT=/usr/local/rbenv
export PATH=$RBENV_ROOT/bin:$PATH
[[ -e "$RBENV_ROOT/bin/rbenv" ]] && eval "$(rbenv init -)"
' >> /etc/profile.d/rbenv.sh

ln -s /usr/local/rbenv/completions/rbenv.bash /etc/bash_completion.d/rbenv

# load rbenv
source /etc/profile.d/rbenv.sh




# install Ruby 1.9.3
CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline" rbenv install 1.9.3-p327
rbenv global 1.9.3-p327

# rehash
rbenv rehash

# restart shell
exec $SHELL