Created
May 2, 2009 00:04
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: something_great.rb | |
# by Jim Garvin (coderifous) | |
# | |
# Useful gems and plugins | |
# | |
# * shoulda/mocha/factory girl | |
# * pacecar for lots of automatic scopes | |
# * haml | |
# * sprockets for javascript management | |
# * will paginate | |
# * limerick_rake gives some nice utilities | |
# * asks for a hoptoad API key, and if given, will setup hoptoad initializer | |
# | |
# Removes a bunch of files/directories that you don't need. | |
# | |
# Creates the typical application layout (under views), and gives you a nice set | |
# of sass files including reset.sass, common.sass and a stub application.sass | |
# | |
# Adds a few things to .gitignore and does initial git commit. | |
@reminder_messages = [] | |
def reminder(msg) | |
@reminder_messages << msg | |
end | |
def report_reminders | |
@reminder_messages.each do |m| | |
puts "* #{m}" | |
end | |
puts | |
end | |
gem "thoughtbot-shoulda", :lib => "shoulda/rails", :source => "http://gems.github.com" | |
gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => "http://gems.github.com" | |
gem "thoughtbot-pacecar", :lib => "pacecar", :source => "http://gems.github.com" | |
gem "floehopper-mocha", :lib => "mocha", :source => "http://gems.github.com" | |
gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gems.github.com" | |
gem "haml" | |
gem "sprockets" | |
plugin "hoptoad_notifier", :git => "git://github.com/thoughtbot/hoptoad_notifier.git" | |
plugin "limerick_rake", :git => "git://github.com/thoughtbot/limerick_rake.git" | |
plugin "dancing_with_sprockets", :git => "git://github.com/coderifous/dancing_with_sprockets.git" | |
plugin "will_paginate", :git => "git://github.com/mislav/will_paginate.git" | |
run "haml --rails ." | |
# Remove some unneeded files/directories. | |
run "rm -R public/index.html public/images/rails.png README doc/README_FOR_APP test/fixtures" | |
# don't load fixtures | |
run "cat test/test_helper.rb | grep -v 'fixtures :all' > test/test_helper.rb" | |
run "mkdir -p app/javascripts/third-party" | |
run "rm -R public/javascripts" | |
file "app/javascripts/application.js", <<EOF | |
//= require <dependency> | |
// Code goes here | |
EOF | |
reminder "Change or delete the first line in app/javascripts/application.js" | |
reminder "Add third party javascript dependencies (like jquery plugins) to app/javascripts/third-party" | |
file "app/views/layouts/application.html.haml", <<EOF | |
!!! 1.1 | |
%html{ "xmlns" => "http://www.w3.org/1999/xhtml", "xml:lang" => "en" } | |
%head | |
%meta{ "http-equiv" => "content-type", "content" => "text/html;charset=UTF-8" } | |
%meta{ "name" => "description", "content" => "..." } | |
%meta{ "name" => "keywords", "content" => "..." } | |
%link{ :rel => "icon", :type => "image/x-icon", :href => "favicon.ico" } | |
%title= "App Name - \#{@page_title || controller.action_name}" | |
= stylesheet_link_tag "application" | |
%script{ :src => "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js", :type => "text/javascript" } | |
= sprockets_include_tag :application | |
= yield :head | |
%body | |
#header | |
#content | |
= yield | |
#footer | |
Copyright Jim Garvin 2009 | |
EOF | |
file "public/stylesheets/sass/_reset.sass", <<EOF | |
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td | |
:margin 0 | |
:padding 0 | |
:border 0 | |
:outline 0 | |
:font-weight inherit | |
:font-style inherit | |
:font-size 100% | |
:font-family inherit | |
:vertical-align baseline | |
*:focus | |
:outline 0 | |
body | |
:line-height 1 | |
:color black | |
:background white | |
ol, ul | |
:list-style none | |
table | |
:border-collapse separate | |
:border-spacing 0 | |
caption, th, td | |
:text-align left | |
:font-weight normal | |
blockquote:before, blockquote:after, q:before, q:after | |
:content "" | |
blockquote, q | |
:quotes "" "" | |
EOF | |
file "public/stylesheets/sass/_common.sass", <<EOF | |
=clearfix | |
display: inline-block | |
&:after | |
content: "." | |
display: block | |
height: 0 | |
clear: both | |
visibility: hidden | |
* html & | |
height: 1px | |
EOF | |
file "public/stylesheets/sass/application.sass", <<EOF | |
@import reset | |
@import common | |
EOF | |
hoptoad_api_key = ask("Enter hoptoad key and press enter, or just press enter to skip: ") | |
unless hoptoad_api_key.blank? | |
file "config/initializers/hoptoad.rb", <<EOF | |
HoptoadNotifier.configure do |config| | |
config.api_key = '#{hoptoad_api_key}' | |
end | |
EOF | |
end | |
file ".gitignore", <<EOF | |
log/*.log | |
log/*.pid | |
db/*.db | |
db/*.sqlite3 | |
db/schema.rb | |
tags | |
tmp/**/* | |
.DS_Store | |
*.swp | |
doc/api | |
doc/app | |
config/database.yml | |
public/stylesheets/*.css | |
coverage/* | |
.dotest/* | |
EOF | |
git :init | |
git :add => "." | |
git :commit => "-a -m 'Start of something great.'" | |
puts "============= Done! =============" | |
puts | |
puts "Don't forget this stuff:" | |
puts | |
report_reminders |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment