Skip to content

Instantly share code, notes, and snippets.

@pyar6329
Last active August 29, 2015 13:55
Show Gist options
  • Save pyar6329/8760277 to your computer and use it in GitHub Desktop.
Save pyar6329/8760277 to your computer and use it in GitHub Desktop.
rails new shellscrpit (github => travis => heroku)
RED=$'\e[0;31;1m'
COLOR_OFF=$'\e[0m'
if [ ! "$#" = "1" ]; then
echo "$RED""please input app_name!""$COLOR_OFF"
else
mkdir "$1"
cd "$1"
touch Gemfile
echo 'source "http://rubygems.org"' >> Gemfile
echo 'gem "rails", "4.0.2"' >> Gemfile
bundle install --path .bundle
bundle exec rails new "$1" --skip-bundle
rm -rf Gemfile
rm -rf Gemfile.lock
rm -rf .bundle
rm -rf vendor
cd "$1"
sed -i -e "/sqlite3/d" Gemfile
echo "" >> Gemfile
echo "# Use sqlite3 as the database for Active Record" >> Gemfile
echo "group :development do" >> Gemfile
echo " gem 'sqlite3'" >> Gemfile
echo "end" >> Gemfile
echo "" >> Gemfile
echo "# Use Travis CI tests" >> Gemfile
echo "group :test do" >> Gemfile
echo " gem 'rake'" >> Gemfile
echo " gem 'rspec-rails'" >> Gemfile
echo "end" >> Gemfile
echo "" >> Gemfile
echo "# Use Heroku deploy" >> Gemfile
echo "group :production do" >> Gemfile
echo " gem 'rails_12factor'" >> Gemfile
echo " gem 'pg'" >> Gemfile
echo " gem 'newrelic_rpm'" >> Gemfile
echo "end" >> Gemfile
echo "" >> Gemfile
echo "# Use travis CI command" >> Gemfile
echo "gem 'travis'" >> Gemfile
bundle install --path .bundle --without test production
mv .* ../
mv * ../
cd ..
rm -rf "$1"
fi
@pyar6329
Copy link
Author

pyar6329 commented Feb 1, 2014

このシェルスクリプトはrailsのひな形を作成するものです。
実際には、github => travis => heroku(postgreSQL)経由で動くためのものです。

準備するもの

  • bundler
  • ruby 2.0.0以上

特徴

  • 環境を汚さない

詳細

  • OSには、「bundlerとrubyだけがインストールされている状態」のまま
  • OSには、railsそのものは、インストールされない
  • railsは、一度bundleでインストールされ、アプリを作成後削除される
  • 作られたアプリの中ではbundle exec rails sは使える
  • gemファイル群は railsアプリのディレクトリの中にインストールされる

実行方法

  • 以下のコマンドを入力する
$ rails_heroku.sh "アプリケーション名"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment