Skip to content

Instantly share code, notes, and snippets.

@nicolas-brousse
Last active December 17, 2015 17:19
Show Gist options
  • Select an option

  • Save nicolas-brousse/5644740 to your computer and use it in GitHub Desktop.

Select an option

Save nicolas-brousse/5644740 to your computer and use it in GitHub Desktop.
#! /bin/sh
#
# Create new empty rails application with rvm
# Author: Nicolas Brousse <nicolas@opsone.net>
# Date: 2011-11-17 00:18:10 UTC
#
# create_rails [version] [gemset_name] PATH
#
set -e
CURRENT_DIR=$(pwd)
function pause(){
read -p "$*"
}
function error_exit {
cd $CURRENT_DIR
set +e
echo ""
echo "########### CREATION FAILED ##########"
exit 1
}
trap "error_exit 'Received signal SIGHUP'" SIGHUP
trap "error_exit 'Received signal SIGINT'" SIGINT
trap "error_exit 'Received signal SIGTERM'" SIGTERM
shopt -s expand_aliases
alias die='error_exit'
#
# Run
#
Run()
{
if [ -z "$1" ] || [ -z "$2" ]; then
echo ""
echo "Usage: \$ ${0##*/} RAILS_VERSION RUBY_VERSION GEMSET_NAME PATH"
echo ""
exit 1
fi
# Init vars
RAILS_VERSION="${1}"
RUBY_VERSION="${2}"
GEMSET_NAME="${3}"
APP_PATH="${4}"
rvm use ${RUBY_VERSION}@${GEMSET_NAME} --create --ruby-version
rails new ${}
}
#
# Run a phase based on the selector
#
Run $1 $2 $3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment