Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Last active August 29, 2015 13:57
Show Gist options
  • Save ejhayes/9828485 to your computer and use it in GitHub Desktop.
Save ejhayes/9828485 to your computer and use it in GitHub Desktop.
Quick and dirty script to setup a base rails app with minimal tests and whatnot
#!/bin/bash
function info {
# Blue'ish
echo -e "\033[1;36m$1\033[0m" 1>&2
}
function error {
# Red'ish
echo -e "\033[1;35m$1\033[0m" 1>&2
}
clear
info "This will setup a base rails app in the current directory. Ctrl + C if you do not want to proceed."
info "Checking ruby..."
which ruby
if [ "$?" != "0" ]; then
error "Ruby not found, aborting"
exit 1
fi
info "Checking gems..."
which gem
if [ "$?" != "0" ]; then
error "Gems not found, aborting"
exit 1
fi
info "Checking bundler"
which bundler
set -e
if [ "$?" != "0" ]; then
gem install bundler --no-ri --no-rdoc
fi
echo -n "Name of app, followed by [ENTER]: ?"
# Get a valid app name from the user
while read app_name; do
if [ -z "${app_name}" ]; then
clear
error "That was empty, do it again!"
echo -n "Name of app, followed by [ENTER]: ?"
else
break
fi
done
# Now do the work
info "Checking out the base repo"
git clone [email protected]:ejhayes/base_rails.git $app_name
cd $app_name
bundle
rails g rename_to $app_name
rm -r "vendor/plugins/Rename"
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake spec
rm -rf .git
git init .
git add .
git commit -m "Initial commit."
info "DONE. Run: 'cd $app_name && rails s' to get started."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment