Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add script for initializing new rails app

  • Loading branch information...
commit d0adc18a92474df63feb8c65ef36d5fa264a12ea 1 parent ec7c442
Slavek Kabrda authored
Showing with 62 additions and 0 deletions.
  1. +62 −0 ruby193-rails-new-app
62 ruby193-rails-new-app
View
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+HELP="Usage: $0 [-p PATH]
+ -p [--path] PATH create application in path PATH (PATH must not exist)
+ relative PATH creates application in current directory
+ Defaults to 'app'."
+
+export NAME=app
+
+ARGS=`getopt -q -o "p:" -l "path:" -- $*`
+
+if [ $? -ne 0 ]; then
+ echo "$HELP"
+ exit 1
+fi
+eval set -- "$ARGS"
+
+while true; do
+ case "$1" in
+ -p|--path)
+ NAME=$2
+ shift 2;;
+ --)
+ if [ -n "$2" ]; then
+ echo "Unexpected parameter '$2'."
+ echo "$HELP"
+ exit 1
+ fi
+ shift
+ break;;
+ esac
+done
+
+NAME=`readlink -m $NAME`
+
+if [ -e $NAME ]; then
+ echo "Directory $NAME already exists, please choose a different path."
+ exit 2
+else
+ mkdir -p $NAME
+fi
+
+scl enable ruby193 - << \EOF
+rails new $NAME --skip-bundle
+if [ $? -eq 0 ]; then
+ pushd $NAME > /dev/null
+ sed -i "s|# gem 'therubyracer'|gem 'therubyracer'|" Gemfile
+ bundle install --local
+cat > develop << DEVELOP
+scl enable ruby193 "PS1='(ruby193)\$PS1' bash"
+DEVELOP
+ popd > /dev/null
+ echo "
+Your application is ready in '$NAME'.
+To get switched to the development environment, use
+
+cd $NAME
+source $NAME/develop"
+else
+ echo 'There was an error creating new application.'
+fi
+EOF
Please sign in to comment.
Something went wrong with that request. Please try again.