Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Last active December 16, 2015 09:49
Show Gist options
  • Save apcomplete/5415979 to your computer and use it in GitHub Desktop.
Save apcomplete/5415979 to your computer and use it in GitHub Desktop.
App Template
client = ask "What's the client name for this project?"
job = ask "What's the job number for this project?"
install_devise = yes? "Do you want to use devise?"
install_rails_admin = yes? "Do you want to use rails_admin?"
gem 'rails-backbone'
gem 'thin'
gem 'capybara', group: [:test,:development]
gem 'rspec-rails', group: [:test,:development]
gem 'faker', group: [:test,:development]
gem 'factory_girl_rails', group: [:test,:development]
gem "annotate", group: [:development]
gem "capistrano", group: [:development]
gem 'bootstrap-sass', group: [:assets]
gem 'compass-rails', group: [:assets]
gem 'unicorn', group: [:production]
gem "devise" if install_devise
gem "rails_admin" if install_rails_admin
run "bundle install"
#Replace db passwords with root
gsub_file "config/database.yml", /password:/, "password: root"
#Create db, necessary for rspec/backbone installs
run 'bundle exec rake db:create'
#Clean up rails defaults
remove_file 'public/index.html'
remove_file 'rm public/images/rails.png'
#Initialize git repo
git :init
append_file ".gitignore", "esproj"
append_file ".gitignore", "sass-cache"
git add: ".", commit: "-m 'Initial Commit'"
#Generate rspec install
generate "rspec:install"
#Customize generators to not include controller/helper/routing/view specs
inject_into_file 'config/application.rb', :after => "config.assets.version = '1.0'" do
<<-eos
# Customize generators
config.generators do |g|
g.test_framework :rspec, :view_specs => false, :controller_specs => false,
:helper_specs => false, :routing_specs => false, :fixture => true,
:fixture_replacement => "factory_girl"
end
eos
end
git add: ".", commit: "-m 'Generate rspec install'"
#Generate backbone install
generate "backbone:install"
git add: ".", commit: "-m 'Generate backbone install'"
if install_devise
generate "devise:install"
generate "devise User"
run "bundle exec rake db:migrate"
git add: ".", commit: "-m 'Generate devise user'"
end
if install_rails_admin
generate "rails_admin:install"
git add: ".", commit: "-m 'Generate rails admin'"
end
if yes? "Do you want to generate a root controller?"
name = ask("What should it be called?").underscore
generate :controller, "#{name} index"
route "root to: '#{name}\#index'"
git add: ".", commit: "-m 'Generate #{name} controller'"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment