Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created December 8, 2014 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannymcc/1d47bcdadb513be988fd to your computer and use it in GitHub Desktop.
Save dannymcc/1d47bcdadb513be988fd to your computer and use it in GitHub Desktop.
#
# Voupe Rails Template
# http://r.dean.io
# rails new awesome -d mysql --skip-spring -m http://rails.dean.io
# http://guides.rubyonrails.org/rails_application_templates.html
#
RUBY_VERSION = "2.1.5"
#
# Remove gems from the Gemfile which we don't want anything to do with
#
original_gemfile = File.read("Gemfile")
new_gemfile = original_gemfile.split("\n").select { |line| line =~ /\A\s*[a-z]/ }
gems_to_remove = ["turbolinks", "jbuilder", "sdoc"]
new_gemfile = new_gemfile.reject do |line|
line =~ /gem ['"](#{gems_to_remove.join('|')})['"]/
end
File.open("Gemfile", 'w') { |f| f.write(new_gemfile.join("\n"))}
#
# Add gems
#
gem "haml"
gem "gonzo"
gem "active_link_to"
gem "nifty-utils"
gem "nilify_blanks"
gem "annotate"
gem "kaminari"
gem "chronic"
gem "dynamic_form"
gem "activevalidators"
gem "bcrypt"
gem "unicorn"
gem_group :development do
gem "powder"
gem "quiet_assets"
gem "app_reset"
gem "better_errors"
gem "binding_of_caller"
gem "letter_opener"
gem "capistrano"
end
gem_group :development, :test do
gem "rspec-rails"
gem "factory_girl_rails"
end
gem_group :test do
gem "simplecov", require: false
gem "faker"
gem "database_cleaner"
gem "capybara"
gem "launchy"
gem "selenium-webdriver"
end
#
# Replace the default template with a HAML one
#
inside "app/views/layouts" do
run "rm application.html.erb"
file "application.html.haml", <<-CODE
!!!
%html
%head
%title #{@page_title}
= javascript_include_tag "application"
= stylesheet_link_tag "application"
= csrf_meta_tags
%body
= flash_display
= yield
CODE
end
#
# Copy the default CSS to SCSS
#
inside "app/assets/stylesheets" do
run "mv application.css application.scss"
end
#
# Copy the default JS to coffeescript
#
inside "app/assets/javascripts" do
file_contents = File.read("application.js").gsub(/\/\//, '##')
File.open("application.coffee", "w") { |f| f.write(file_contents) }
run "rm application.js"
end
#
# Remove turbolinks from application.coffee
#
inside "app/assets/javascripts" do
content = File.readlines("application.coffee").reject do |line|
line =~ /\A##= require turbolinks/
end
File.open("application.coffee", 'w') { |f| f.write(content.join) }
end
#
# Disable all generators
#
environment <<-CODE
config.generators do |g|
g.orm :active_record
g.stylesheets false
g.javascripts false
g.helper false
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: true,
request_specs: true
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
CODE
#
# Add autoload path
#
environment 'config.autoload_paths += %W(#{config.root}/lib)'
#
# Remove default rdoc readme & add markdown version
#
readme = "# #{app_name}\n\nThis is the Ruby on Rails application for #{app_name}"
File.open("README.md", "w") { |f| f.write(readme) }
run "rm README.rdoc"
#
# RVM Setup
#
file ".ruby-version", RUBY_VERSION
file ".ruby-gemset", app_name
run "rvm ruby-#{RUBY_VERSION} do rvm gemset create #{app_name}"
#
# Create Pow file
#
file ".powrc", <<-CODE
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".ruby-gemset" ]; then
rvm use `cat .ruby-version`@`cat .ruby-gemset`
else
rvm use `cat .ruby-version`
fi
fi
CODE
#
# Gem installation
#
run "bundle install"
#
# Powder
#
run "powder link"
#
# Commit before we begin
#
git :init
git :add => "."
git :commit => %Q{-m 'Initial commit'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment