Created
March 4, 2014 18:53
-
-
Save wyattisimo/9353105 to your computer and use it in GitHub Desktop.
Sinatra Starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sets up a simple Sinatra project. | |
# Assumes RVM, Bundler and Foreman. | |
if [ $# -lt 1 ] || [ $# -gt 2 ]; then | |
echo Expected 1 or 2 arguments but got $# | |
echo Usage: sinatra-starter PROJECT_NAME [RUBY_VERSION] | |
exit | |
fi | |
project_name=$1 | |
if [ -z $2 ]; then | |
ruby_version=`rvm-prompt` | |
else | |
ruby_version=$2 | |
fi | |
mkdir $project_name | |
if test $? -eq 1; then | |
echo Unable to create project | |
exit | |
fi | |
cd $project_name | |
printf "require 'bundler/setup'\nBundler.require :default\n" >> app.rb | |
printf "source 'https://rubygems.org'\n\ngem 'sinatra'\n" >> Gemfile | |
echo "web: ruby app.rb" >> Procfile | |
touch .env | |
source ~/.rvm/scripts/rvm | |
rvm use $ruby_version | |
rvm gemset create $project_name | |
rvm --ruby-version use $ruby_version@$project_name | |
bundle | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment