Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
Forked from bjreath/rails.rb
Created March 18, 2010 16:57
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 stevenhaddox/336559 to your computer and use it in GitHub Desktop.
Save stevenhaddox/336559 to your computer and use it in GitHub Desktop.
# File permissions
run "chmod 755 ."
%w(public log tmp).each do |dir|
run "chmod -R 755 #{dir}"
end
# Remove unnecessary files
%w(README public/index.html public/favicon.ico public/robots.txt).each do |file|
run "rm #{file}"
end
run "rm -f public/javascripts/*"
run "rm -rf doc/"
run "rm -rf test/"
# Replace environment.rb with a slightly cleaner file
file ("config/environment.rb", %q(RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
config.time_zone = 'UTC'
end
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "<mailserver>"
}
ActionMailer::Base.perform_deliveries = true
))
# Install default gems
gem "binarylogic-authlogic", :lib => "authlogic", :version => "2.1.0", :source => "http://gems.github.com"
gem "mislav-will_paginate", :lib => "will_paginate", :version => "2.3.11", :source => "http://gems.github.com"
gem "mysql", :version => "2.7"
rake "gems:install", :sudo => true
# Install default plugins
# exception_notification
# ssl_requirement
# Testing setup
gem "cucumber", :lib => false, :version => "0.3.11", :env => "test"
gem "webrat", :lib => false, :version => "0.4.4", :env => "test"
gem "rspec", :lib => false, :version => "1.2.7", :env => "test"
gem "rspec-rails", :lib => "spec/rails", :version => "1.2.7.1", :env => "test"
gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => "http://gems.github.com", :env => "test"
rake "gems:install", :env => "test", :sudo => true
generate :rspec
generate :cucumber
# Separate directories for mailers, observers, and sweepers
%w(app/mailers app/mailers/views app/observers app/sweepers).each do |dir|
run "mkdir #{dir}"
end
environment %q(
%w(observers sweepers mailers).each do |dir|
config.load_paths << "#{RAILS_ROOT}/app/#{dir}"
end
)
file("app/mailers/application_mailer.rb", %q(class ApplicationMailer < ActionMailer::Base
self.template_root = File.join(RAILS_ROOT, 'app', 'mailers', 'views')
end
))
# Download JQuery
run "curl -L http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js > public/javascripts/jquery.js"
run "curl -L http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js > public/javascripts/jquery-ui.js"
# Setup seed data
rakefile("seed.rake") do
<<-TASK
namespace :db do
task :reset => ["db:drop", "db:setup"]
task :setup => ["db:create", "db:schema:load", "db:seed"]
task :seed do
seed_file = File.join(Rails.root, "db", "seeds.rb")
load(seed_file) if File.exist?(seed_file)
end
end
TASK
end
run "touch db/seeds.rb"
# Session store initializer
initializer 'session_store.rb', <<-END
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
END
# Database setup
rake "db:drop db:create db:sessions:create db:migrate"
rake "db:drop db:create db:sessions:create db:migrate", :env => "test"
# Setup Git and .gitignore files
git :init
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore app/models/.gitignore app/views/.gitignore"
run "touch app/mailers/views/.gitignore app/observers/.gitignore app/sweepers/.gitignore"
run "cp config/database.yml config/database.yml.sample"
file '.gitignore', <<-END
.DS_Store
log/*.log
tmp/**/*
tmp/*
config/database.yml
END
git :add => "."
git :commit => "-m 'First commit of project'"
# Finished
puts "Finished Rails template!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment