Skip to content

Instantly share code, notes, and snippets.

@pcg79
Forked from coderifous/something_great.rb
Created May 2, 2009 17:46
Show Gist options
  • Save pcg79/105638 to your computer and use it in GitHub Desktop.
Save pcg79/105638 to your computer and use it in GitHub Desktop.
# Rails Template: something_great.rb
# by Jim Garvin (coderifous)
#
# * 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
@todo_messages = []
def todo(msg)
@todo_messages << msg
end
def report_todos
@todo_messages.each do |m|
puts "* #{m}"
end
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 "sprocket-rails", :git => "git://github.com/pangloss/sprockets-rails.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"
# =============
# Sprockets
# =============
route "SprocketsApplication.routes(map, :resources)"
file "config/sprockets.yml", <<EOF
:defaults: &defaults
:asset_root: public
:load_path:
- app/javascripts
- app/javascripts/third-party
:example:
<<: *defaults
:source_files:
- app/javascripts/example.js
EOF
todo "Edit config/sprockets.yml"
todo "Change or delete example entry."
run "mkdir -p app/javascripts/third-party"
run "rm -R public/javascripts"
run "rmdir vendor/sprockets"
file "app/javascripts/example.js", <<EOF
//= require <dependency>
// Code goes here
EOF
todo "Change or delete example.js"
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 :example
= 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
tmp/**/*
.DS_Store
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_todos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment