Skip to content

Instantly share code, notes, and snippets.

@gvarela
Forked from defeated/Rails-3-App-Template.rb
Last active September 25, 2015 11:08
Show Gist options
  • Save gvarela/911641 to your computer and use it in GitHub Desktop.
Save gvarela/911641 to your computer and use it in GitHub Desktop.
# include gems
gem 'pg'
gem 'haml-rails'
gem 'jquery-rails'
gem 'has_scope'
gem 'will_paginate'
gem 'simple_form'
gem 'utensils', github: 'modeset/utensils'
gem 'unicorn'
gem_group :assets do
gem 'haml_coffee_assets'
end
gem_group :test do
gem 'rspec'
gem 'rspec-rails'
gem 'cucumber'
gem 'cucumber-rails'
gem 'capybara'
gem 'shoulda-matchers'
gem 'database_cleaner'
end
run 'bundle install'
# Set up generator defaults
generators = <<-RUBY
config.generators do |g|
g.template_engine :haml
g.stylesheets false
g.javascripts false
g.helpers false
g.test_framework :rspec, :fixture => false
g.helper_specs false
g.view_specs false
g.controller_specs false
end
RUBY
application generators
# Remove files we don't care about
remove_file "public/index.html"
remove_file "public/favicon.ico"
remove_file "public/robots.txt"
remove_file "public/images/rails.png"
remove_file "README"
say "Creating a nicer default README"
create_file 'README.md', <<-FILE.gsub(/^ {2}/, '')
#{app_name.humanize}
===========
* http://github.com/modeset/#{app_name}
* Application-specific documentation and notes go here.
FILE
# Create a sane robots.txt
robots_txt = <<-ROBOTS.gsub(/^ {2}/, '')
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
User-Agent: *
Disallow: /admin
ROBOTS
create_file "public/robots.txt", robots_txt
# Keep the log and tmp directories intact
create_file "log/.gitkeep"
create_file "tmp/.gitkeep"
# Create a .gitignore file and a new local repository, commit everything
remove_file '.gitignore'
file '.gitignore', <<-CODE.gsub(/^ {2}/, '')
# System stuff
.DS_Store
.bundle
.idea
.rake_tasks
.rvmrc
.powenv
REVISION
vendor/bundle
.rake_tasks~
mkmf.log
# Local config files
config/database.yml
config/*.sphinx.conf
config/mongoid.yml
# Local DBs
db/sphinx
db/*.sqlite3
# Logs
log/*.log
log/*.pid
# Tempfiles
tmp/
tmp/**/*
coverage
capybara*
# Assets
public/system
public/static
/assets
packages
CODE
# Tweak app layout to use HAML
layout = <<-LAYOUT.gsub(/^ {2}/, '')
!!!
%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
generate('rspec:install')
generate('cucumber:install', '--rspec')
generate('simple_form:install', '--bootstrap')
generate('utensils:install')
git :add => '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment