Created
July 2, 2009 07:52
-
-
Save bigblue/139320 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 template built from a variety of sources - mostly suspenders template. | |
# Uses cached_externals plugin to manage plugins/gems | |
# Search and replace "CHANGEME" with your project name before running | |
# ==================== | |
# ==================== | |
# CONFIG | |
# ==================== | |
plugin 'cached_externals', :git => "git://github.com/37signals/cached_externals.git" | |
# Use database (active record) session store | |
rake('db:sessions:create') | |
run "capify ." | |
file 'config/environment.rb', | |
%q{# Be sure to restart your server when you modify this file | |
# Change this to the name of your rails project, like carbonrally. | |
# Just use the same name as the svn repo. | |
PROJECT_NAME = "CHANGEME" | |
throw "The project's name in environment.rb is blank" if PROJECT_NAME.empty? | |
throw "Project name (#{PROJECT_NAME}) must_be_like_this" unless PROJECT_NAME =~ /^[a-z_]*$/ | |
# Specifies gem version of Rails to use when vendor/rails is not present | |
RAILS_GEM_VERSION = '2.3.0' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
Rails::Initializer.run do |config| | |
# Settings in config/environments/* take precedence over those specified here. | |
# Application configuration should go into files in config/initializers | |
# -- all .rb files in that directory are automatically loaded. | |
# See Rails::Configuration for more options. | |
# Skip frameworks you're not going to use. To use Rails without a database | |
# you must remove the Active Record framework. | |
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ] | |
# Specify gems that this application depends on. | |
config.gem 'thoughtbot-quietbacktrace', :lib => 'quietbacktrace', | |
:version => '1.1.7' | |
config.gem 'nokogiri', :version => '1.3.2' | |
config.gem 'cucumber', :version => '0.3.11' | |
config.gem 'haml', :version => '2.1.0' | |
# Only load the plugins named here, in the order given. By default, all plugins | |
# in vendor/plugins are loaded in alphabetical order. | |
# :all can be used as a placeholder for all plugins not explicitly named | |
# config.plugins = [ :exception_notification, :ssl_requirement, :all ] | |
# Add the vendor/gems/*/lib directories to the LOAD_PATH | |
config.load_paths += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'gems', '*', 'lib')) | |
# Force all environments to use the same logger level | |
# (by default production uses :info, the others :debug) | |
# config.log_level = :debug | |
# Make Time.zone default to the specified zone, and make Active Record store time values | |
# in the database in UTC, and return them converted to the specified local zone. | |
# Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time. | |
config.time_zone = 'UTC' | |
# Use SQL instead of Active Record's schema dumper when creating the test database. | |
# This is necessary if your schema can't be completely dumped by the schema dumper, | |
# like if you have constraints or database-specific column types | |
# config.active_record.schema_format = :sql | |
# Activate observers that should always be running | |
# config.active_record.observers = :cacher, :garbage_collector | |
end | |
} | |
file 'config/deploy.rb', | |
%q{set :stages, %w(staging production) | |
set :default_stage, 'staging' | |
require 'capistrano/ext/multistage' | |
#before "deploy:setup" | |
namespace :deploy do | |
desc "Default deploy - updated to run migrations" | |
task :default do | |
set :migrate_target, :latest | |
update_code | |
migrate | |
symlink | |
restart | |
end | |
desc "Restarting passenger with restart.txt" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "touch #{current_path}/tmp/restart.txt" | |
end | |
[:start, :stop].each do |t| | |
desc "#{t} task is a no-op with mod_rails" | |
task t, :roles => :app do ; end | |
end | |
desc "Run this after every successful deployment" | |
task :after_default do | |
cleanup | |
end | |
end | |
} | |
file 'config/deploy/staging.rb', | |
%q{# For migrations | |
set :rails_env, 'staging' | |
# Who are we? | |
set :application, 'CHANGEME' | |
set :repository, "[email protected]:thoughtbot/#{application}.git" | |
set :scm, "git" | |
set :deploy_via, :remote_cache | |
set :branch, "staging" | |
# Where to deploy to? | |
role :web, "staging.example.com" | |
role :app, "staging.example.com" | |
role :db, "staging.example.com", :primary => true | |
# Deploy details | |
set :user, "#{application}" | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :use_sudo, false | |
set :checkout, 'export' | |
} | |
file 'config/deploy/production.rb', | |
%q{# For migrations | |
set :rails_env, 'production' | |
# Who are we? | |
set :application, 'CHANGEME' | |
set :repository, "[email protected]:thoughtbot/#{application}.git" | |
set :scm, "git" | |
set :deploy_via, :remote_cache | |
set :branch, "production" | |
# Where to deploy to? | |
role :web, "production.example.com" | |
role :app, "production.example.com" | |
role :db, "production.example.com", :primary => true | |
# Deploy details | |
set :user, "#{application}" | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :use_sudo, false | |
set :checkout, 'export' | |
} | |
file 'config/environments/development.rb', | |
%q{# Settings specified here will take precedence over those in config/environment.rb | |
# In the development environment your application's code is reloaded on | |
# every request. This slows down response time but is perfect for development | |
# since you don't have to restart the webserver when you make code changes. | |
config.cache_classes = false | |
# Log error messages when you accidentally call methods on nil. | |
config.whiny_nils = true | |
# Show full error reports and disable caching | |
config.action_controller.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
config.action_view.debug_rjs = true | |
# Don't care if the mailer can't send | |
config.action_mailer.raise_delivery_errors = false | |
HOST = 'localhost' | |
} | |
file 'config/environments/production.rb', | |
%q{# Settings specified here will take precedence over those in config/environment.rb | |
# The production environment is meant for finished, "live" apps. | |
# Code is not reloaded between requests | |
config.cache_classes = true | |
# Use a different logger for distributed setups | |
# config.logger = SyslogLogger.new | |
# Full error reports are disabled and caching is turned on | |
config.action_controller.consider_all_requests_local = false | |
config.action_controller.perform_caching = true | |
# Enable serving of images, stylesheets, and javascripts from an asset server | |
# config.action_controller.asset_host = "http://assets.example.com" | |
# Disable delivery errors, bad email addresses will be ignored | |
config.action_mailer.raise_delivery_errors = false | |
} | |
file 'config/environments/staging.rb', | |
%q{# Settings specified here will take precedence over those in config/environment.rb | |
# We'd like to stay as close to prod as possible | |
# Code is not reloaded between requests | |
config.cache_classes = true | |
# Full error reports are disabled and caching is turned on | |
config.action_controller.consider_all_requests_local = false | |
config.action_controller.perform_caching = true | |
# Disable delivery errors if you bad email addresses should just be ignored | |
config.action_mailer.raise_delivery_errors = false | |
} | |
file 'config/environments/test.rb', | |
%q{# Settings specified here will take precedence over those in config/environment.rb | |
# The test environment is used exclusively to run your application's | |
# test suite. You never need to work with it otherwise. Remember that | |
# your test database is "scratch space" for the test suite and is wiped | |
# and recreated between test runs. Don't rely on the data there! | |
config.cache_classes = true | |
# Log error messages when you accidentally call methods on nil. | |
config.whiny_nils = true | |
# Show full error reports and disable caching | |
config.action_controller.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
# Disable request forgery protection in test environment | |
config.action_controller.allow_forgery_protection = false | |
# Tell ActionMailer not to deliver emails to the real world. | |
# The :test delivery method accumulates sent emails in the | |
# ActionMailer::Base.deliveries array. | |
config.action_mailer.delivery_method = :test | |
config.gem 'metric_fu', :version => '1.1.1' | |
HOST = 'localhost' | |
require 'quietbacktrace' | |
} | |
inside('db') do | |
run "mkdir bootstrap" | |
end | |
#==================== | |
# PLUGINS & GEMS | |
#==================== | |
file 'config/externals.yml', | |
%q{--- | |
vendor/rails: | |
:type: git | |
:repository: git://github.com/rails/rails.git | |
:revision: 73fc42cc0b5e94541480032c2941a50edd4080c2 | |
vendor/gems/cucumber-0.3.11: | |
:type: git | |
:repository: git://github.com/aslakhellesoy/cucumber.git | |
:revision: 41c07a9e768eb54b9cb6bb72e531016370111653 | |
vendor/gems/haml-2.1.0: | |
:type: git | |
:repository: git://github.com/nex3/haml.git | |
:revision: ef58f87f789bc4705bcde5c12723a362556d79f8 | |
vendor/gems/metric_fu-1.1.1: | |
:type: git | |
:repository: git://github.com/jscruggs/metric_fu.git | |
:revision: 2310717a928cdc436e0cf1803ad271bf0ac001dd | |
vendor/gems/nokogiri-1.3.2: | |
:type: git | |
:repository: git://github.com/tenderlove/nokogiri.git | |
:revision: d23fe2c4094d054858dbd9dab1d0d21b94495604 | |
vendor/gems/thoughtbot-quietbacktrace-1.1.7: | |
:type: git | |
:repository: git://github.com/thoughtbot/quietbacktrace.git | |
:revision: 95332f416e32293f9f9777f6e6035fd9d2412bc3 | |
vendor/plugins/asset_packager: | |
:type: git | |
:repository: git://github.com/sbecker/asset_packager.git | |
:revision: 8407a666e1eb586995c8a2d094d1eefe4a9b6f8e | |
vendor/plugins/faker: | |
:type: git | |
:repository: git://github.com/yyyc514/faker.git | |
:revision: 7027f8b1b0fd35f4f3ccfaf5c1de460efd81b2c2 | |
vendor/plugins/formtastic: | |
:type: git | |
:repository: git://github.com/justinfrench/formtastic.git | |
:revision: de14a5db4b91ed283611a4b37fdfab4543dbda79 | |
vendor/plugins/hoptoad_notifier: | |
:type: git | |
:repository: git://github.com/thoughtbot/hoptoad_notifier.git | |
:revision: 2a5f0e4216aad75171b10c2aa5adfd121543840c | |
vendor/plugins/limerick_rake: | |
:type: git | |
:repository: git://github.com/thoughtbot/limerick_rake.git | |
:revision: d8e102e152c4c96f7ad57f07452c8b43c0805971 | |
vendor/plugins/machinist: | |
:type: git | |
:repository: git://github.com/notahat/machinist.git | |
:revision: d7874cab873f5331c9a3031bfe7fe1834a9af742 | |
vendor/plugins/paperclip: | |
:type: git | |
:repository: git://github.com/thoughtbot/paperclip.git | |
:revision: 121609fab38f2aba5ac3cbe0d6b26fd664ee3090 | |
vendor/plugins/shoulda: | |
:type: git | |
:repository: git://github.com/thoughtbot/shoulda.git | |
:revision: c86a6de3857e560cf8b3920f1589824690338196 | |
vendor/plugins/webrat: | |
:type: git | |
:repository: git://github.com/brynary/webrat.git | |
:revision: 6697ecd2d36d401dd7b2c73e63c4adf9fcd2f130 | |
vendor/plugins/will_paginate: | |
:type: git | |
:repository: git://github.com/mislav/will_paginate.git | |
:revision: b3b0f593ea9b1da13a64bc825dfe17b6bbc2828b | |
} | |
run "mkdir vendor/gems" | |
run "cap local externals:setup" | |
run "rake gems:build" | |
run "rake gems:refresh_specs" | |
run "rake gems:refresh_specs RAILS_ENV=test" | |
#==================== | |
# INITIALIZERS | |
#==================== | |
initializer 'action_mailer_configs.rb', | |
%q{ActionMailer::Base.smtp_settings = { | |
:address => "smtp.domain.com", | |
:port => 25, | |
:domain => "domain.com" | |
} | |
} | |
initializer 'errors.rb', | |
%q{# Example: | |
# begin | |
# some http call | |
# rescue *HTTP_ERRORS => error | |
# notify_hoptoad error | |
# end | |
HTTP_ERRORS = [Timeout::Error, | |
Errno::EINVAL, | |
Errno::ECONNRESET, | |
EOFError, | |
Net::HTTPBadResponse, | |
Net::HTTPHeaderSyntaxError, | |
Net::ProtocolError] | |
#SMTP_SERVER_ERRORS = [TimeoutError, | |
# IOError, | |
# Net::SMTPServerBusy, | |
# Net::SMTPAuthenticationError] | |
# | |
#SMTP_CLIENT_ERRORS = [Net::SMTPFatalError, | |
# Net::SMTPSyntaxError] | |
# | |
#SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS | |
} | |
initializer 'hoptoad.rb', <<-FILE | |
HoptoadNotifier.configure do |config| | |
config.api_key = 'HOPTOAD-KEY' | |
end | |
FILE | |
initializer 'session_store.rb', <<-FILE | |
ActionController::Base.session = { :session_key => '_#{(1..6).map { |x| (65 + rand(26)).chr }.join}_session', :secret => '#{(1..40).map { |x| (65 + rand(26)).chr }.join}' } | |
ActionController::Base.session_store = :active_record_store | |
FILE | |
initializer 'requires.rb', | |
%q{Dir[File.join(RAILS_ROOT, 'lib', 'extensions', '*.rb')].each do |f| | |
require f | |
end | |
Dir[File.join(RAILS_ROOT, 'lib', '*.rb')].each do |f| | |
require f | |
end | |
} | |
initializer 'time_formats.rb', | |
%q{# Example time formats | |
{ :short_date => "%x", :long_date => "%a, %b %d, %Y" }.each do |k, v| | |
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update(k => v) | |
end | |
} | |
#==================== | |
# APP | |
#==================== | |
file 'app/controllers/application_controller.rb', | |
%q{class ApplicationController < ActionController::Base | |
helper :all | |
protect_from_forgery | |
include HoptoadNotifier::Catcher | |
end | |
} | |
file 'app/helpers/application_helper.rb', | |
%q{module ApplicationHelper | |
def body_class | |
"#{controller.controller_name} #{controller.controller_name}-#{controller.action_name}" | |
end | |
end | |
} | |
file 'app/views/layouts/_flashes.html.erb', | |
%q{<div id="flash"> | |
<% flash.each do |key, value| -%> | |
<div id="flash_<%= key %>"><%=h value %></div> | |
<% end -%> | |
</div> | |
} | |
file 'app/views/layouts/application.html.erb', | |
%q{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title><%= PROJECT_NAME.humanize %></title> | |
<%= stylesheet_link_tag 'screen', :media => 'all', :cache => true %> | |
<%= javascript_include_tag :defaults, :cache => true %> | |
</head> | |
<body class="<%= body_class %>"> | |
<%= render :partial => 'layouts/flashes' -%> | |
<%= yield %> | |
</body> | |
</html> | |
} | |
# ==================== | |
# TEST | |
# ==================== | |
file 'test/blueprints.rb', %q{require 'machinist/active_record' | |
require 'sham' | |
} | |
file 'test/shoulda_macros/forms.rb', | |
%q{class Test::Unit::TestCase | |
def self.should_have_form(opts) | |
model = self.name.gsub(/ControllerTest$/, '').singularize.downcase | |
model = model[model.rindex('::')+2..model.size] if model.include?('::') | |
http_method, hidden_http_method = form_http_method opts[:method] | |
should "have a #{model} form" do | |
assert_select "form[action=?][method=#{http_method}]", eval(opts[:action]) do | |
if hidden_http_method | |
assert_select "input[type=hidden][name=_method][value=#{hidden_http_method}]" | |
end | |
opts[:fields].each do |attribute, type| | |
attribute = attribute.is_a?(Symbol) ? "#{model}[#{attribute.to_s}]" : attribute | |
assert_select "input[type=#{type.to_s}][name=?]", attribute | |
end | |
assert_select "input[type=submit]" | |
end | |
end | |
end | |
def self.form_http_method(http_method) | |
http_method = http_method.nil? ? 'post' : http_method.to_s | |
if http_method == "post" || http_method == "get" | |
return http_method, nil | |
else | |
return "post", http_method | |
end | |
end | |
end | |
} | |
file 'test/shoulda_macros/pagination.rb', | |
%q{class Test::Unit::TestCase | |
# Example: | |
# context "a GET to index logged in as admin" do | |
# setup do | |
# login_as_admin | |
# get :index | |
# end | |
# should_paginate_collection :users | |
# should_display_pagination | |
# end | |
def self.should_paginate_collection(collection_name) | |
should "paginate #{collection_name}" do | |
assert collection = assigns(collection_name), | |
"Controller isn't assigning to @#{collection_name.to_s}." | |
assert_kind_of WillPaginate::Collection, collection, | |
"@#{collection_name.to_s} isn't a WillPaginate collection." | |
end | |
end | |
def self.should_display_pagination | |
should "display pagination" do | |
assert_select "div.pagination", { :minimum => 1 }, | |
"View isn't displaying pagination. Add <%= will_paginate @collection %>." | |
end | |
end | |
# Example: | |
# context "a GET to index not logged in as admin" do | |
# setup { get :index } | |
# should_not_paginate_collection :users | |
# should_not_display_pagination | |
# end | |
def self.should_not_paginate_collection(collection_name) | |
should "not paginate #{collection_name}" do | |
assert collection = assigns(collection_name), | |
"Controller isn't assigning to @#{collection_name.to_s}." | |
assert_not_equal WillPaginate::Collection, collection.class, | |
"@#{collection_name.to_s} is a WillPaginate collection." | |
end | |
end | |
def self.should_not_display_pagination | |
should "not display pagination" do | |
assert_select "div.pagination", { :count => 0 }, | |
"View is displaying pagination. Check your logic." | |
end | |
end | |
end | |
} | |
file 'test/test_helper.rb', | |
%q{ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + "/../config/environment") | |
require 'test_help' | |
require 'action_view/test_case' | |
require File.expand_path(File.dirname(__FILE__) + "/blueprints") | |
require "webrat" | |
Webrat.configure do |config| | |
config.mode = :rails | |
end | |
class Test::Unit::TestCase | |
self.use_transactional_fixtures = true | |
self.use_instantiated_fixtures = false | |
self.backtrace_silencers << :rails_vendor | |
self.backtrace_filters << :rails_root | |
setup { Sham.reset } | |
end | |
class ActionView::TestCase | |
# Enable UrlWriter when testing helpers | |
include ActionController::UrlWriter | |
# Default host for helper tests | |
default_url_options[:host] = HOST | |
end | |
} | |
#==================== | |
# GIT SETUP | |
#==================== | |
run 'rm README' | |
run 'rm public/index.html' | |
run 'rm public/favicon.ico' | |
run 'rm public/images/rails.png' | |
# rails:rm_tmp_dirs | |
["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f| | |
run("rmdir ./#{f}") | |
end | |
# git:hold_empty_dirs | |
run("find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;") | |
# git:rails:new_app | |
git :init | |
initializer '.gitignore', <<-CODE | |
log/\\*.log | |
log/\\*.pid | |
db/\\*.db | |
db/\\*.sqlite3 | |
db/schema.rb | |
tmp/\\*\\*/\\* | |
.DS_Store | |
doc/api | |
doc/app | |
config/database.yml | |
CODE | |
run "cp config/database.yml config/database.yml.sample" | |
git :add => "." | |
git :commit => "-a -m 'Setting up a new rails app. Copy config/database.yml.sample to config/database.yml and customise.'" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment