Skip to content

Instantly share code, notes, and snippets.

@wyattisimo
Created March 4, 2014 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wyattisimo/9353105 to your computer and use it in GitHub Desktop.
Save wyattisimo/9353105 to your computer and use it in GitHub Desktop.
Sinatra Starter
#!/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