Created
July 24, 2015 16:57
-
-
Save paganotoni/a090e8b79e9a7c45ee63 to your computer and use it in GitHub Desktop.
Ruby project initialization script.
This file contains hidden or 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
# 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