Skip to content

Instantly share code, notes, and snippets.

@nclark
Forked from Lytol/ultemplate.rb
Created October 24, 2011 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nclark/1310316 to your computer and use it in GitHub Desktop.
Save nclark/1310316 to your computer and use it in GitHub Desktop.
Rails 3 Application Template
# Rails application template for Rails 3 + Postgres + Git + haml + JQuery + Rspec + Cucumber + Capybara + FactoryGirl
# by Brian Smith <bsmith@swig505.com>
# 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