Skip to content

Instantly share code, notes, and snippets.

@yasuoza
Created November 14, 2012 09:02
Show Gist options
  • Save yasuoza/4071096 to your computer and use it in GitHub Desktop.
Save yasuoza/4071096 to your computer and use it in GitHub Desktop.
Rails3 Application template
# -*- coding: utf-8 -*-
#
# Usage
#
# rails new yourapp -m https://raw.github.com/gist/4071096/4541b3f89f63d906156b429c7d5779231a1d23bb/rails3_application_template.rb -T --skip-bundle
#
use_rspec = yes?('Do you want to use rspec?')
use_slim = yes?('Do you want to use slim?')
unless use_slim
use_haml = yes?('Do you want to use haml?')
end
run 'rm .gitignore'
get 'https://raw.github.com/github/gitignore/master/Rails.gitignore', '.gitignore'
insert_into_file '.gitignore', "/public/assets/*\n", after: "/public/system/*\n"
if use_slim
gem 'slim-rails'
end
if use_haml
gem 'haml-rails'
end
if use_rspec
gem_group :development, :test do
gem 'rspec-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'spork', '~> 1.0rc'
gem 'simplecov', :require => false
gem 'simplecov-rcov'
end
end
gem_group :development do
gem 'pry'
gem 'pry-doc'
gem 'pry-rails'
end
run 'bundle install --path vendor/bundle --binstubs'
if use_rspec
run 'script/rails generate rspec:install'
run 'bundle exec spork rspec -b'
spec_helper_file = "spec/spec_helper.rb"
contents = File.read(spec_helper_file)
File.open(spec_helper_file, "wb") do |f|
f.puts <<-'RUBY'
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'
RUBY
f.puts contents
end
insert_into_file '.rspec', "--drb", after: "--color\n"
end
git :init
git :add => '.', :commit => '-m "Initial commit"'
@yasuoza
Copy link
Author

yasuoza commented Nov 14, 2012

Support Rails4.0

path/to/rails/railties/bin/rails new yourapp -m https://raw.github.com/gist/4071096/8afaa3e068c5c4e12cd8a8ba559d036ab9728b96/rails3_application_template.rb -T --skip-bundle --edge

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