Skip to content

Instantly share code, notes, and snippets.

@botandrose
Created June 12, 2009 21:42
Show Gist options
  • Save botandrose/128945 to your computer and use it in GitHub Desktop.
Save botandrose/128945 to your computer and use it in GitHub Desktop.
# bard.rb
# bot and rose design rails template
NAME = @root.split("/").last
# delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm -f public/javascripts/*"
run "rm -rf test"
run "rm -rf doc"
# general.sass
file "public/stylesheets/sass/general.sass", <<-END
END
# Download JQuery
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js > public/javascripts/jquery.js"
# run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
# Set up .gitignore files
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore}
file '.gitignore', <<-END
log/*.log
tmp/*
!tmp/.gitignore
.DS_Store
public/cache/**/*
doc/api
doc/app
doc/spec/*
db/data.*
db/*.sqlite3
config/database.yml
config/deploy.rb
converage/**/*
Capfile
*[~]
END
# Set up databases
file "config/database.yml", <<-END
login: &login
adapter: mysql
database: #{NAME}
username: root
password:
socket: /var/run/mysqld/mysqld.sock
development:
<<: *login
test:
<<: *login
database: #{NAME}_test
staging:
<<: *login
password: thecakeisalie
production:
<<: *login
END
rake "db:create"
rake "db:migrate"
# Install plugins
plugin "acts_as_list", :git => "git://github.com/rails/acts_as_list.git"
#plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git'
#plugin 'exception_notification', :git => 'git://github.com/rails/exception_notification.git'
#plugin 'fckeditor', :git => 'git://github.com/originofstorms/fckeditor.git'
# Install gems
gem "haml"
gem "giraffesoft-resource_controller", :lib => "resource_controller", :source => "http://gems.github.com"
gem "RedCloth", :lib => "redcloth"
rake "gems:install", :sudo => true
# Testing Environment
gem "rspec", :lib => false
gem "rspec-rails", :lib => false
gem "webrat", :lib => false
gem "cucumber", :lib => false
gem "notahat-machinist", :lib => "machinist", :source => "http://gems.github.com"
rake "gems:install", :sudo => true
plugin 'cucumber_rails_debug', :git => "git://github.com/mischa/cucumber_rails_debug"
generate "rspec"
generate "cucumber"
run "rake db:create RAILS_ENV=test"
# Staging Environment
run "cp config/environments/development.rb config/environments/staging.rb"
# Restart task
file "lib/tasks/restart.rake", <<-END
task :restart do
system("touch tmp/restart.txt")
system("touch tmp/debug.txt") if ENV["DEBUG"] == 'true'
end
END
# Set up git repository
git :init
git :add => "."
git :commit => "-am 'initial commit.'"
# Set up static controller
if true #yes? "Set up for static pages?"
file "app/controllers/static_controller.rb", <<-END
class StaticController < ApplicationController
def dispatch
view_template_path = "/static/"+params[:path].join("/")
begin
render view_template_path, :layout => true
rescue ActionView::MissingTemplate
begin
render view_template_path+"/index", :layout => true
rescue ActionView::MissingTemplate
raise ActiveRecord::RecordNotFound
end
end
end
end
END
route "map.connect '*path', :controller => 'static', :action => 'dispatch'"
route "map.root :controller => 'static', :action => 'dispatch', :path => ['index']"
file "app/views/static/index.html.haml", <<-END
%h1 #{NAME}
END
git :add => "."
git :commit => "-am 'static controller.'"
end
# Deployment and staging setup
file "Capfile", <<-END
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load '../cap.tasks'
load 'config/deploy'
END
file "config/deploy.rb", <<-END
set :application, "#{NAME}"
END
git :remote => "add origin [email protected]:#{NAME}"
run "cap staging:bootstrap"
# Success!
puts "SUCCESS!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment