Last active
August 29, 2015 14:06
-
-
Save ko2ic/aca5194cd2a2519a4ff7 to your computer and use it in GitHub Desktop.
Railsローカルインストールからプロジェクト作成の半自動化 ref: http://qiita.com/ko2ic/items/f2ad0f326552794b8b67
This file contains 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
function gi() { curl https://www.gitignore.io/api/$@ ;} | |
function rails_new(){ | |
while read -p "Please enter project name: " railsName ; do | |
if [ -n "$railsName" ] ; then | |
break | |
fi | |
done | |
while read -p "Whether use Test::Unit[y/n] " skipTest ; do | |
case $skipTest in | |
[Yy]* ) | |
skipTest='' | |
break | |
;; | |
[Nn]* ) | |
skipTest='-T' | |
break | |
;; | |
*) | |
echo "Please answer yes or no." | |
;; | |
esac | |
done | |
read -p "Please enter rails version: " version | |
if [ -n "$version" ] ; then | |
version=", \"$version\"" | |
fi | |
cat << EOS > Gemfile | |
source "http://rubygems.org" | |
gem "rails"$version | |
EOS | |
bundle install --path vendor/bundle | |
bundle exec rails new $railsName --skip-bundle $skipTest | |
rm -f Gemfile | |
rm -f Gemfile.lock | |
rm -rf .bundle | |
rm -rf vendor | |
cd $railsName | |
if [ "$skipTest" != "" ] ; then | |
cat << EOS >> Gemfile | |
gem 'rspec-rails', group: [:development, :test] | |
gem 'factory_girl_rails', group: [:development, :test] | |
EOS | |
fi | |
bundle install --path vendor/bundle | |
if [ "$skipTest" != "" ] ; then | |
bundle exec rails g rspec:install | |
fi | |
gi rails > .gitignore | |
} |
This file contains 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
function gi() { curl https://www.gitignore.io/api/$@ ;} | |
function rails_new(){ | |
while read -p "Please enter project name: " railsName ; do | |
if [ -n "$railsName" ] ; then | |
break | |
fi | |
done | |
while read -p "Whether use Test::Unit[y/n] " skipTest ; do | |
case $skipTest in | |
[Yy]* ) | |
skipTest='' | |
break | |
;; | |
[Nn]* ) | |
skipTest='-T' | |
break | |
;; | |
*) | |
echo "Please answer yes or no." | |
;; | |
esac | |
done | |
read -p "Please enter rails version: " version | |
if [ -n "$version" ] ; then | |
version=", \"$version\"" | |
fi | |
cat << EOS > Gemfile | |
source "http://rubygems.org" | |
gem "rails"$version | |
EOS | |
bundle install --path vendor/bundle | |
bundle exec rails new $railsName --skip-bundle $skipTest | |
rm -f Gemfile | |
rm -f Gemfile.lock | |
rm -rf .bundle | |
rm -rf vendor | |
cd $railsName | |
if [ "$skipTest" != "" ] ; then | |
cat << EOS >> Gemfile | |
gem 'rspec-rails', group: [:development, :test] | |
gem 'factory_girl_rails', group: [:development, :test] | |
EOS | |
fi | |
bundle install --path vendor/bundle | |
if [ "$skipTest" != "" ] ; then | |
bundle exec rails g rspec:install | |
fi | |
gi rails > .gitignore | |
} |
This file contains 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
$ rails_new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment