Created
May 14, 2010 15:21
-
-
Save arnklint/401285 to your computer and use it in GitHub Desktop.
This file contains 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
# To use: | |
# rails project_name -m http://gist.github.com/raw/401285/963cbb5d75644d545d0b81be02b1656b365932e7/rails-template.rb | |
# download helper | |
require 'net/http' | |
def download(url, target_dir = "") | |
domain = url.match(/:\/\/([a-z\.]*)/)[1] | |
filename = url.match(/\/([a-z\.]*)$/)[1] | |
path = url.match(/:\/\/[a-z\.]*(.*)/)[1] | |
if target_dir | |
target_path = [target_dir, filename].join("/") | |
else | |
target_path = filename | |
end | |
puts target_path | |
Net::HTTP.start(domain) do |http| | |
resp = http.get(path) | |
open(target_path, "wb") do |file| | |
file.write(resp.body) | |
end | |
end | |
end | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" | |
run "rm public/javascripts/dragdrop.js" | |
run "rm public/javascripts/effects.js" | |
run "rm public/javascripts/prototype.js" | |
# add basic layout to start | |
file 'app/views/layouts/application.html.erb', <<-HTML | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>Application!</title> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<script src="/javascripts/jquery.min.js" type="text/javascript"></script> | |
<script src="/javascripts/jquery-ui.min.js" type="text/javascript"></script> | |
<%= stylesheet_link_tag 'global' %> | |
</head> | |
<body> | |
<%= yield %> | |
</body> | |
</html> | |
HTML | |
# download jquery instead | |
download("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts") | |
file 'config/database.yml', <<-CODE | |
# SQLite version 3.x | |
# gem install sqlite3-ruby (not necessary on OS X Leopard) | |
development: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
# Warning: The database defined as "test" will be erased and | |
# re-generated from your development database when you run "rake". | |
# Do not set this db to the same as development or production. | |
test: | |
adapter: sqlite3 | |
database: db/test.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
production: | |
adapter: sqlite3 | |
database: db/production.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
CODE | |
# Testing Helper | |
file 'test/test_helper.rb', <<-CODE | |
ENV['RAILS_ENV'] = 'test' | |
require File.expand_path(File.dirname(__FILE__) + '/../config/environment') | |
require 'test_help' | |
require 'shoulda' | |
require 'mocha' | |
require 'factory_girl' | |
CODE | |
# Testing tools | |
gem 'redgreen' | |
gem 'shoulda' | |
gem 'factory_girl' | |
gem 'mocha' | |
# Gem management | |
rake 'gems:install' | |
rake 'gems:unpack' | |
# create dev db | |
rake 'db:create' | |
# source control | |
file '.gitignore', <<-FILES | |
.DS_Store | |
**/.DS_Store | |
log/* | |
tmp/* | |
tmp/**/* | |
coverage/* | |
coverage/**/* | |
FILES | |
git :init | |
git :add => '.' | |
git :commit => '-a -m "Initial commit"' | |
exec "mate ." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment