Skip to content

Instantly share code, notes, and snippets.

@paganotoni
Created July 24, 2015 16:57
Show Gist options
  • Save paganotoni/a090e8b79e9a7c45ee63 to your computer and use it in GitHub Desktop.
Save paganotoni/a090e8b79e9a7c45ee63 to your computer and use it in GitHub Desktop.
Ruby project initialization script.
# Initialization for a ruby project
PROJECTS_DIR="/Users/$(whoami)/Projects"
rubyinit(){
PROJECT_NAME="$1"
PROJECT_FOLDER="$2"
if [ -z "$PROJECT_NAME" ]; then
echo "| ERROR You must specify a project name!"
return
fi
if [ -z "$PROJECT_FOLDER" ]; then
PROJECT_FOLDER="$PROJECTS_DIR/$PROJECT_NAME"
fi
if [ -d "$PROJECT_FOLDER" ]; then
echo "| ERROR folder alredy exists"
return
fi
mkdir "$PROJECT_FOLDER"
echo "| Directory created"
touch $PROJECT_FOLDER/{Gemfile,.ruby-version,.ruby-gemset,.editorconfig}
echo "| Base files created"
git init -q $PROJECT_FOLDER
echo "| Git initialized"
gitignore Ruby "$PROJECT_FOLDER/.gitignore"
echo "| Added Gitignore"
echo "source \"https://rubygems.org\"" >> "$PROJECT_FOLDER/Gemfile"
export BUNDLE_GEMFILE="$PROJECT_FOLDER/Gemfile"
bundle install
echo "| \o/ Ruby project initialized!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment