Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created June 3, 2009 16:18
Show Gist options
  • Select an option

  • Save ryanbriones/123068 to your computer and use it in GitHub Desktop.

Select an option

Save ryanbriones/123068 to your computer and use it in GitHub Desktop.
export RAILS_APP_TEMPLATE="http://gist.github.com/raw/123068/5db3cf1fbef8d8e0608a2e98afa59c32518fe160/ryanbriones.rb"
railst() {
if [ $# -gt 1 ]; then
railst_usage
else
rails -m $RAILS_APP_TEMPLATE $1
cd $1
fi
}
railst_usage() {
echo "Usage: railst /path/to/your/app"
} >&2
# ryanbriones.rb
# My Personal Rails Application Template
# stolen from mocra.rb (http://github.com/drnic/rails-templates/blob/master/mocra.rb)
# wrap template commands in block so their execution can be controlled
# in unit testing
def template(&block)
@store_template = block
end
template do
run "rm doc/README_FOR_APP"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm public/images/rails.png"
run "rm -f public/javascripts/*"
run "rm -rf test"
file "README", ""
file 'app/controllers/application_controller.rb', <<-EOS.gsub(/^ /, '')
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
end
EOS
file 'app/helpers/application_helper.rb', <<-EOS.gsub(/^ /, '')
module ApplicationHelper
end
EOS
file 'config/environment.rb', <<-EOS.gsub(/^ /, '')
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.time_zone = 'UTC'
end
EOS
file 'config/routes.rb', <<-EOS.gsub(/^ /, '')
ActionController::Routing::Routes.draw do |map|
end
EOS
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', <<-EOS.gsub(/^ /, '')
.DS_Store
log/*.log
tmp/**/*
config/database.yml
config/initializers/site_keys.rb
EOS
git :init
git :add => '.'
git :commit => "-m 'initialize rails application'"
###################
file 'public/javascripts/jquery-1.3.2.js', open('http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js').read
file 'public/javascripts/application.js', <<-EOS.gsub(/^ /, '')
(function($) {
})(jQuery);
EOS
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
generate 'rspec'
git :add => '.'
git :commit => "-m 'add jquery and rails plugins'"
end
def run_template
@store_template.call
end
run_template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment