larrybotha
8/11/2015 - 2:25 PM

Install our development ruby environment

Install our development ruby environment

#!/usr/bin/env bash

set -eo pipefail

# Install rbenv
if [[ ! -d ~/.rbenv ]]; then
	echo "Installing rbenv"
  git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
	if [[ ! `grep 'eval "\$(rbenv init -)"' ~/.bashrc` ]]; then
		echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
		echo 'eval "$(rbenv init -)"' >> ~/.bashrc
	fi
  git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
fi

if [[ -z "$RUBY_VERSION" ]];then
  RUBY_VERSION=2.1.0
fi
  
if [[ -f /app/.ruby-version ]]; then
	RUBY_VERSION=$(< /app/.ruby-version)
fi

. ~/.bash_profile

# Install ruby version
if [[ ! `rbenv versions | grep $RUBY_VERSION` ]];then
  rbenv install $RUBY_VERSION
fi
rbenv global $RUBY_VERSION

gem install bundler

rbenv rehash