Created
September 23, 2010 07:02
-
-
Save Lytol/593259 to your computer and use it in GitHub Desktop.
Rails 3 Application Template
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 application template for Rails 3 + Postgres + Git + haml + JQuery + Rspec + Cucumber + Capybara + FactoryGirl | |
# by Brian Smith <[email protected]> | |
# Create a default README | |
file "README.md", <<-EOF | |
#{app_name} | |
#{"=" * app_name.length} | |
TODO: description | |
Getting Started | |
--------------- | |
TODO: how to get app running | |
EOF | |
# Remove unwanted defaults | |
remove_file "README" | |
remove_file "public/index.html" | |
remove_file "public/images/rails.png" | |
run "rm -rf test" | |
run "rm -rf autotest" # Others may use this, but I don't... so bye-bye! | |
# Create default Gemfile | |
remove_file "Gemfile" | |
file "Gemfile", <<-EOF | |
source "http://rubygems.org" | |
gem "rails" | |
gem "pg" | |
gem "haml" | |
gem "sass" | |
group :development, :test do | |
gem "capybara" | |
gem "cucumber" | |
gem "cucumber-rails" | |
gem "rspec-rails" | |
gem "factory_girl_rails" | |
gem "database_cleaner" | |
end | |
EOF | |
# RVM | |
run "rvm gemset create #{app_name}" | |
run "rvm 1.9.2@#{app_name} gem install bundler" | |
run "rvm 1.9.2@#{app_name} -S bundle install" | |
file ".rvmrc", <<-EOF | |
rvm --create use ruby-1.9.2@#{app_name} | |
EOF | |
# Generator config | |
application <<-EOF | |
config.generators do |g| | |
g.orm :active_record | |
g.template_engine :haml | |
g.test_framework :rspec | |
g.fixture_replacement :factory_girl | |
g.helper false | |
end | |
EOF | |
# Database | |
remove_file "config/database.yml" | |
database_config = <<-EOF | |
development: | |
adapter: postgresql | |
encoding: unicode | |
database: #{app_name}_dev | |
test: | |
adapter: postgresql | |
encoding: unicode | |
database: #{app_name}_test | |
EOF | |
file "config/database.yml", database_config | |
file "config/database.yml-example", database_config | |
# Haml and SASS | |
remove_file "app/views/layouts/application.html.erb" | |
file "app/views/layouts/application.html.haml", <<-EOF | |
!!! | |
%html | |
%head | |
%title #{app_name.humanize} | |
= stylesheet_link_tag :all | |
= javascript_include_tag :defaults | |
= csrf_meta_tag | |
%body | |
= yield | |
EOF | |
# Cucumber and RSpec | |
run "rvm 1.9.2@#{app_name} -S rails generate rspec:install" | |
run "rvm 1.9.2@#{app_name} -S rails generate cucumber:install --rspec --capybara" | |
# Create DB and migrate | |
run "rvm 1.9.2@#{app_name} -S rake db:create:all" | |
run "rvm 1.9.2@#{app_name} -S rake db:migrate" | |
# Git init + add everything | |
remove_file ".gitignore" | |
file ".gitignore", <<-EOF | |
.DS_Store | |
.bundle | |
*.swp | |
*.swo | |
config/database.yml | |
db/*.sqlite3 | |
log/*.log | |
tmp/**/* | |
EOF | |
git :init | |
git :add => "." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment