Created
April 4, 2014 11:07
-
-
Save slowjack2k/9972395 to your computer and use it in GitHub Desktop.
Simple template for a new Rails-App using some nice extra gems. Call with: rails new app_name --skip-test-unit -m template.rb
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
def after_bundler_callbacks | |
@after_bundler_callbacks ||= [] | |
end | |
def run_bundle | |
super | |
run_after_bundler_callbacks unless options[:skip_gemfile] || options[:skip_bundle] | |
end | |
def run_after_bundler_callbacks | |
after_bundler_callbacks.each {|c| c.call} | |
end | |
def after_bundler(&block) | |
after_bundler_callbacks << block | |
end | |
def say_custom(text) | |
say "\033[1m\033[36mtemplate\033[0m #{text}" | |
end | |
after_bundler do | |
say_custom "installing RSpec" | |
generate 'rspec:install' | |
say_custom "generate additional rspec files" | |
file 'spec/acceptance/.keep', "" | |
file 'spec/integration/.keep', "" | |
file 'spec/unit/.keep', "" | |
file 'spec/support/.keep', "" | |
file 'spec/acceptance_spec_helper.rb', <<-CODE | |
require 'spec_helper' | |
CODE | |
file 'spec/integration_spec_helper.rb', <<-CODE | |
require 'spec_helper' | |
CODE | |
file 'spec/unit_spec_helper.rb', <<-CODE | |
require 'spec_helper' | |
CODE | |
say_custom "init guard" | |
run "bundle exec guard init" | |
say_custom "init capistrano" | |
run "cap install" | |
say_custom "git commit" | |
git :init | |
git add: "." | |
git commit: "-a -m 'Initial commit'" | |
end | |
say_custom "update used gems" | |
gem_group :development, :test do | |
# Use debugger | |
gem 'debugger' | |
# testing with spec | |
gem 'rspec-rails', '2.99.0.beta1' | |
# show nicely how many specs have to be run | |
gem 'fuubar' | |
# extented console | |
gem 'pry-rails' | |
gem 'pry-remote' | |
# https://github.com/pry/pry-stack_explorer | |
gem 'pry-stack_explorer' | |
# https://github.com/nixme/pry-debugger | |
gem 'pry-debugger' | |
# generate fake things like words names addresses | |
gem "ffaker" | |
# https://github.com/jfirebaugh/konacha | |
# testing javascript based on mocha and chai | |
gem 'konacha' | |
# all chai matchers | |
gem 'konacha-chai-matchers' | |
# headless driver for browser tests | |
gem 'poltergeist' | |
end | |
gem_group :development do | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'meta_request' | |
# automatic execute tasks on file changes | |
gem 'guard' | |
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i | |
# exec specs | |
gem 'guard-rspec', require: false | |
# reload page in browser after view file changed | |
gem 'guard-livereload', require: false | |
gem "rack-livereload" | |
# restart the webserver from time to time | |
gem 'guard-rails' | |
# bundle install after gemfile change | |
gem 'guard-bundler' | |
# https://github.com/alexgb/guard-konacha | |
# run konacha when needed | |
gem 'guard-konacha' | |
# server for dev env | |
gem 'thin' | |
# quite asset messages in development mode | |
# https://github.com/evrone/quiet_assets | |
# to reenable via config | |
# config.quiet_assets = false | |
gem 'quiet_assets' | |
# source maps for chrome to easier debug coffee script, only chrome until now | |
# delete tmp/cache/assets/development/ and restart server to use it | |
gem 'coffee-rails-source-maps' | |
end | |
gem_group :test do | |
# factory replacement | |
gem 'fabrication' | |
end | |
gem 'anjlab-bootstrap-rails', require: 'bootstrap-rails', | |
github: 'anjlab/bootstrap-rails' | |
# font awesome without bootstrap | |
gem 'font-awesome-sass' | |
# easier css handling like sprites and browser idepentend css generation | |
gem 'compass-rails' | |
gem_group :production do | |
gem 'unicorn' | |
end | |
gem 'capistrano', '~> 3.1.0' | |
gem 'capistrano-rvm' | |
gem 'capistrano-rails' | |
gem 'capistrano3-unicorn' | |
gem 'unicorn-worker-killer' | |
gem "gelf" | |
gem "lograge" | |
say_custom "remove turbolinks" | |
gsub_file "Gemfile", /.*turbolinks.*/, "\n" | |
gsub_file "app/assets/javascripts/application.js", /.*turbo.*/, "\n" | |
say_custom "change production to use graylog" | |
asset_host = ask("Which asset host for production?") | |
log_host = ask("Which logging host for production?") | |
application(nil, env: "production") do | |
"config.asset_host = #{asset_host} | |
config.lograge.enabled = true | |
config.lograge.log_format = :graylog2 | |
config.logger = GELF::Logger.new('#{log_host}', 12201, 'WAN', { :facility => 'rails' }) | |
config.force_ssl = true | |
" | |
end | |
say_custom "create rvm version.conf" | |
ruby_version=ask("which ruby version?") | |
gem_set=ask("which gemset?") | |
file '.version.conf', <<CODE | |
ruby=#{ruby_version} | |
ruby-gemset=#{gem_set} | |
#ruby-gem-install=bundler rake | |
#ruby-bundle-install=true | |
CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment