rails プロジェクトでスタートダッシュを決める
DESCRIPTION
広島Ruby勉強会 #033 の LT 資料です。 https://github.com/hiroshimarb/hiroshimarb.github.com/wiki/2013年8月の活動 LT 資料をつくるのに調べかとこと http://blog.eiel.info/blog/2013/08/03/rails-new-template/TRANSCRIPT
Rails プロジェクトでスタートダッシュを決める
2013-08-03 広島Ruby勉強会 #033
13年8月3日土曜日
対象者
• rails してる人•よく rails new する人
13年8月3日土曜日
こんな人はごめんなさい
13年8月3日土曜日
`rails new` なんかしたことねーよ
13年8月3日土曜日
Rails プロジェクトをはじめるときいつも同じことをしてませんか?
13年8月3日土曜日
プロジェクトの
はじめにありがちなこと
13年8月3日土曜日
• rspec インストールする
• rspec 設定する
• cucumber インストールする
• pry インストールする
13年8月3日土曜日
• 各gem の Github 見にいって設定
• 別のプロジェクトからコピペ
13年8月3日土曜日
めんどくさい
13年8月3日土曜日
自動化したい
13年8月3日土曜日
--template, -m
13年8月3日土曜日
rails new --templateってのがあるらしい
13年8月3日土曜日
• URL も可能• rails new の bundle install の前に•処理を追加できる•DSL を使ってかく
rails new --template ファイル名
13年8月3日土曜日
できること
• rails generate でできること•ファイル作成• bundle install• Gemfile 編集• rake 実行
13年8月3日土曜日
自分で書きたくない場合
13年8月3日土曜日
Rails Composerhttp://railsapps.github.io/rails-composer/
$ rails new myapp \ -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
13年8月3日土曜日
質問に答えていくだけ
13年8月3日土曜日
試してみました
13年8月3日土曜日
試してみた
• rspec インストール• pry-byebug インストール•コミット済み• rails g scaffold
13年8月3日土曜日
rspec_and_pry_template.rbhttps://gist.github.com/eiel/6132727
13年8月3日土曜日
Gemfile 編集
gem_group :development, :test do gem 'rspec-rails', '~> 2.0' gem 'pry-rails' gem 'pry-byebug'end
13年8月3日土曜日
bundle install
run_bundle
13年8月3日土曜日
initial commit
git :initgit add: '.'git commit: "-m 'initial commit'"
13年8月3日土曜日
rails g rspec:install
generate 'rspec:install'
13年8月3日土曜日
second commit
git add: '.'git commit: "-m 'rspec install'"
13年8月3日土曜日
rails g scaffold
generate :scaffold, 'user name:string'
13年8月3日土曜日
試してみる
$ rails new myapp -m $ cd myapp $ rake db:migrate$ rake spec# スペックの実行
$ rails c# pry が起動する
http://goo.gl/py8KSt
https://gist.github.com/eiel/6132727/raw/f99ffc17f1dc399518704966033d53da942167cd/rspec_and_pry_template.rb
13年8月3日土曜日
もっと具体的な話
13年8月3日土曜日
文献• Rails Application Templates• http://guides.rubyonrails.org/rails_application_templates.html
• Creating and Customizing Rails Generators & Templates
• http://guides.rubyonrails.org/generators.htm
13年8月3日土曜日
試したときのメモ
• http://blog.eiel.info/blog/2013/08/03/rails-new-template/
13年8月3日土曜日
知ってると良さそうなこと
• Rails::Generators::AppGenerator•のインスタンスのコンテキストで実行• Thor というライブラリがベース• bundler や vagrant などでも利用されてる
13年8月3日土曜日
知ってると良さそうなこと
• Generator と共通する親クラス• Rails::Generators::Base• Rails::AppBuilder• AppGenerator が生成して、利用する• ::AppBuilder があればこれを利用する
13年8月3日土曜日
まとめ
13年8月3日土曜日
• rails ですぐに開発をはじめられる•Generator と共通の機能を使う• Thor というライブラリに依存してる
13年8月3日土曜日
ご清聴ありがとうございます
13年8月3日土曜日