Skip to content

Instantly share code, notes, and snippets.

@eightbitraptor
Created August 20, 2012 13:26
Show Gist options
  • Save eightbitraptor/3404018 to your computer and use it in GitHub Desktop.
Save eightbitraptor/3404018 to your computer and use it in GitHub Desktop.
bootstrap.sh
#!/usr/bin/env bash
set -e
EXPECTED_ARGS=2
main(){
check_arguments $*
return_to=$PWD
context=$1
project_name=$2
mkdir $project_name && cd $project_name
create_default_gemfile $context
case $context in
"rails" )
yes | bundle exec rails new . ;;
"ruby" )
mkdir lib
touch lib/$project_name.rb
esac
cd $return_to
}
create_default_gemfile() {
echo "source :rubygems" > Gemfile
if [[ "$1" = "rails" ]]; then
echo 'gem "rails"' >> Gemfile
fi
bundle install
}
check_arguments(){
if [ $# -ne $EXPECTED_ARGS ]; then
echo "usage: `basename $0` <rails|ruby> <project_name>"
exit 1;
fi
}
main $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment