Created
August 29, 2011 11:49
-
-
Save willnet/1178242 to your computer and use it in GitHub Desktop.
rails template for 3.1
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
# -*- coding: utf-8 -*- | |
# | |
# Usage | |
# | |
# rails new yourapp -m https://raw.github.com/gist/1178242/3c77cfffeb99f32d19333de986ff41283aa9eb26/rails_template_for_3.1.rb -T --skip-bundle | |
# | |
git :init | |
append_file '.gitignore', <<-END | |
.rbenv-version | |
vendor/bundle | |
END | |
gem 'annotate', :git => 'https://github.com/ctran/annotate_models.git', :group => :development | |
gem 'i18n_generators', :group => :development | |
gem 'active_reload', :group => :development | |
heroku = yes?('do you want to use heroku?') | |
haml = yes?('do you want to use haml?') | |
autotest = yes?('do you want auto-test environment?') | |
mail = yes?('do you want to use mail in your app?') | |
main_controller = yes?('do you want to use main controller?') | |
error_page = yes?('do you want error page?') | |
if heroku | |
gem 'therubyracer-heroku', :group => :production | |
gem 'pg', :group => :production | |
gem 'heroku' | |
end | |
if haml | |
gem 'haml-rails' | |
end | |
if autotest | |
gem 'rspec-rails', :group => [:development, :test] | |
gem 'fabrication', :group => :test | |
gem 'capybara', :group => :test | |
gem 'database_cleaner', :group => :test | |
gem 'launchy', :group => :test | |
gem 'guard-rspec' ,:group => :test | |
gem 'guard-spork', :group => :test | |
gem 'guard-bundler', :group => :test | |
gem 'guard-pow', :group => :test | |
gem 'webmock', :group => :test | |
gem 'timecop', :group => :test | |
gem 'rb-fsevent', :require => false, :group => :test | |
gem 'spork', "> 0.9.0.rc", :group => [:development, :test] | |
gem 'growl', :group => :test | |
gem 'simplecov', :require => false, :group => :test | |
end | |
if mail | |
gem 'mailcatcher', :group => :development | |
end | |
run 'bundle install --path vendor/bundle --without production --binstubs' | |
if autotest | |
run 'script/rails generate rspec:install' | |
run 'bundle exec spork rspec -b' | |
file 'Guardfile', <<-'END' | |
guard 'bundler' do | |
watch('Gemfile') | |
# Uncomment next line if Gemfile contain `gemspec' command | |
# watch(/^.+\.gemspec/) | |
end | |
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :wait => 30 do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch(%r{^config/environments/.*\.rb$}) | |
watch(%r{^config/initializers/.*\.rb$}) | |
watch('spec/spec_helper.rb') | |
watch(%r{^spec/support/.+\.rb$}) | |
end | |
guard 'rspec', :version => 2, :cli => "--drb", :all_on_start => false, :all_after_pass => false do | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
watch('spec/spec_helper.rb') { "spec" } | |
# Rails example | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] } | |
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | |
watch('spec/spec_helper.rb') { "spec" } | |
watch('config/routes.rb') { "spec/routing" } | |
watch('app/controllers/application_controller.rb') { "spec/controllers" } | |
# Capybara request specs | |
watch(%r{^app/views/(.+)/.*\.(erb|haml|coffee)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } | |
end | |
END | |
inject_into_file "config/application.rb", :after => "class Application < Rails::Application\n" do | |
str =<<-"END" | |
config.generators do |g| | |
g.test_framework :rspec, :fixture => true | |
g.fixture_replacement :fabrication | |
end | |
END | |
str | |
end | |
end | |
git :add => '.', :commit => '-m "initial commit"' | |
if main_controller | |
generate 'controller', 'main index' | |
route 'root :to => "main#index"' | |
git :rm => 'public/index.html' | |
git :add => '.', :commit => "-m 'added main controller'" | |
end | |
if error_page | |
run 'mkdir app/views/appliation' | |
file "app/views/appliation/error500.#{ haml ? 'haml' : 'html' }.erb", <<-'END' | |
エラーが発生しました | |
END | |
file "app/views/appliation/error403.#{ haml ? 'haml' : 'html' }.erb", <<-'END' | |
このページを表示する権限がありません | |
END | |
file "app/views/appliation/error404.#{ haml ? 'haml' : 'html' }.erb", <<-'END' | |
ご指定になったページは存在しません | |
END | |
git :add => '.', :commit => "-m 'added error pages'" | |
end | |
if mail | |
inject_into_file "config/environments/development.rb", :after => "Application.configure do\n" do | |
str =<<-"END" | |
config.action_mailer.default_url_options = { :host => '#{app_name}.dev' } | |
config.action_mailer.smtp_settings = {:host => "localhost", :port => 1025} | |
END | |
str | |
end | |
git :add => '.', :commit => "-m 'added mail config for development'" | |
end | |
if heroku | |
puts %!please modify "gem 'sqlite3' -> gem 'sqlite3', :group => [:development, :test]"! | |
end | |
if autotest | |
puts 'please modify spec_helper for spork!' | |
end | |
if error_page | |
puts 'please modify application_controller.rb and routes.rb' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment