Skip to content

Instantly share code, notes, and snippets.

@mynameisrufus
Created January 7, 2011 09:39
Show Gist options
  • Save mynameisrufus/769291 to your computer and use it in GitHub Desktop.
Save mynameisrufus/769291 to your computer and use it in GitHub Desktop.
Rails3 app template (jQuery, RSpec, Cucumber, Machinist, Devise)
# Run using $ rails new [appname] -JT -m new.rb
# GEMS
gem 'rails', '3.0.3'
gem 'compass', '0.10.6'
gem 'devise', '1.1.5'
gem 'cancan', '1.4.1'
# unversioned gems
gem 'pg'
gem 'awesome_print'
gem 'rspec-rails', '2.1.0', :group => [:test, :cucumber]
gem 'cucumber-rails', '0.3.2', :group => [:test, :cucumber]
gem 'machinist', '2.0.0.beta2', :group => [:test, :cucumber]
gem 'capybara', '0.4.0', :group => [:test, :cucumber]
# unversioned gems
gem 'faker', :group => [:test, :cucumber]
gem 'shoulda', :group => [:test, :cucumber]
gem 'launchy', :group => [:test, :cucumber]
gem 'database_cleaner', :group => [:test, :cucumber]
gem 'guard', :group => [:test, :cucumber]
gem 'guard-rspec', :group => [:test, :cucumber]
# linux
gem 'rb-inotify', :group => [:test, :cucumber]
gem 'libnotify', :group => [:test, :cucumber]
# mac osx
# gem 'rb-fsevent'
# gem 'growl'
## Generators
inject_into_file('config/application.rb', :after => "config.i18n.default_locale = :de") do
%q{
config.generators do |g|
g.fixture_replacement :machinist
g.orm :active_record
g.template_engine :haml
g.test_framework :rspec
end
Sass::Plugin.options[:template_location] = { 'app/stylesheets' => 'public/stylesheets' }
}
end
# Latest jQuery UJS
# get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
# HACK: Since the get method hates https and redirects
jquery = open("https://github.com/rails/jquery-ujs/raw/master/src/rails.js").read
create_file "public/javascripts/rails.js", jquery
# Replace the blank one with jQuery served via Google CDN
gsub_file 'config/application.rb', 'config.action_view.javascript_expansions[:defaults] = %w()', 'config.action_view.javascript_expansions[:defaults] = %w(http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js rails.js)'
# Run all the generators
generate "rspec:install"
generate "cucumber:install --capybara --rspec"
generate "machinist:install"
generate "devise:install"
generate "devise User"
## Files
# Clear the default index
remove_file "public/index.html"
# Make a blank application javascript file
remove_file "public/javascripts/application.js"
create_file "public/javascripts/application.js"
# Make the SASS directory and base file
empty_directory "app/stylsheets"
create_file "app/stylesheets/application.scss"
## Layout
layout = <<-LAYOUT
!!!
%html
%head
%title #{app_name.humanize}
= stylesheet_link_tag :all
= javascript_include_tag :defaults
= csrf_meta_tag
%body
= yield
LAYOUT
remove_file "app/views/layouts/application.html.erb"
create_file "app/views/layouts/application.html.haml", layout
## Git
gitignore = <<-END
.bundle
.DS_Store
db/*.sqlite3
log/*.log
tmp/**/*
public/stylesheets/*
*.swp
END
# Re-Make gitignore
remove_file ".gitignore"
create_file ".gitignore", gitignore
# Setup Machinist
empty_directory 'spec/support'
run "bundle install"
git :init
git :add => "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment