Jake.codes

Newsin, For Starting New Sinatra Projects

Saturday, April 13, 2013

Quick Bash alias for starting a new Sintra project.

# newsin - Create a new basic Sinatra project.
newsin() {
    if [ $# -ne 1 ] ; then
        echo "newsin [project name]"
        echo "    Create a new basic Sinatra project."
        return 1
    else
      
        mkdir $1;

        echo "# $1
" > $1/README.md;

        echo "source 'https://rubygems.org'
gem 'sinatra'" > $1/Gemfile;

        echo "# config.ru
# rackup -p 4567
require 'rubygems'
require 'bundler'
Bundler.require

require './$1.rb'
run Sinatra::Application" > $1/config.ru;

        echo "require 'rubygems'
require 'sinatra'

get '/' do
    ''
end" > $1/$1.rb;

    fi
}