Last active
August 29, 2015 14:12
-
-
Save chalmagean/d958409b3ef23ec6b2c4 to your computer and use it in GitHub Desktop.
Rails Template
This file contains 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
# Here's how you generate the app | |
# rails new YourNewApp-m template.rb -B -T | |
# Gems | |
# ================================================== | |
# Use unicorn as the app server | |
gem 'unicorn' | |
if yes?("Use ExceptionNotifier?") | |
gem 'exception_notification' | |
end | |
if yes?("Use Whenerver?") | |
gem 'whenever' | |
end | |
if yes?("Use Sitemaps") | |
gem 'sitemap_generator' | |
end | |
if using_devise = yes?("Use Devise?") | |
gem 'devise' | |
say "Don't forget to run:" | |
say " rails g devise:install" | |
say " rails g devise User" | |
end | |
if yes?("Use Alchemy?") | |
gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: 'master' | |
say "Don't forget to run rake alchemy:install" | |
end | |
gem_group :development, :test do | |
gem "rspec-rails" | |
gem 'spring' | |
gem 'spring-commands-rspec' | |
gem 'spring-commands-cucumber' | |
gem 'byebug' | |
gem 'mailcatcher' | |
gem 'pry-rails' | |
end | |
gem_group :development do | |
gem 'better_errors' | |
gem 'binding_of_caller' | |
gem 'foreman' | |
gem 'quiet_assets' | |
gem 'pretty_backtrace' | |
end | |
gem_group :test do | |
# Capybara for integration testing (https://github.com/jnicklas/capybara) | |
gem "capybara" | |
gem "capybara-webkit" | |
gem 'capybara-email' | |
gem 'cucumber-rails', :require => false | |
gem 'shoulda-matchers' | |
gem 'email_spec' | |
gem 'selenium-webdriver' | |
gem "launchy" | |
gem "factory_girl_rails" | |
gem "database_cleaner" | |
end | |
say "Don't forget to run:" | |
say " rails g rspec:install" | |
say " rails g cucumber:install" | |
say " rails g email_spec:steps" | |
# Remove normal files we don't want | |
remove_file "README.rdoc" | |
remove_file "public/index.html" | |
remove_file "app/assets/images/rails.png" | |
# Copy database.yml to sample | |
inside "config" do | |
run "cp database.yml database.yml.sample" | |
end | |
# Write our config/database.yml | |
if options[:database].to_s == "postgresql" | |
remove_file "config/database.yml" | |
create_file "config/database.yml", <<-EOF | |
login: &login | |
adapter: postgresql | |
encoding: unicode | |
username: root | |
timeout: 5000 | |
pool: 5 | |
development: | |
<<: *login | |
database: #{app_name}_development | |
min_messages: warning | |
test: | |
<<: *login | |
database: #{app_name}_test | |
min_messages: warning | |
end | |
EOF | |
end | |
# Setting up foreman to deal with environment variables and services | |
# https://github.com/ddollar/foreman | |
# ================================================== | |
# Use Procfile for foreman | |
run "echo 'web: bundle exec rails server -p $PORT' >> Procfile" | |
run "echo 'mailcatcher: mailcatcher -f' >> Procfile" | |
run "echo PORT=3000 >> .env" | |
run "echo '.env' >> .gitignore" | |
# Clean up Assets | |
# ================================================== | |
# Use SASS extension for application.css | |
run "mv app/assets/stylesheets/application.css app/assets/stylesheets/application.css.scss" | |
# Remove the require_tree directives from the SASS and JavaScript files. | |
# It's better design to import or require things manually. | |
run "sed -i '' /require_tree/d app/assets/javascripts/application.js" | |
run "sed -i '' /require_tree/d app/assets/stylesheets/application.css.scss" | |
if yes?("Use Bootstrap?") | |
gem 'bootstrap-sass' | |
gem 'devise-bootstrap-views' if using_devise | |
run "echo '@import \"bootstrap-sprockets\";' >> app/assets/stylesheets/application.css.scss" | |
run "echo '@import \"bootstrap\";' >> app/assets/stylesheets/application.css.scss" | |
end | |
if yes?("Use Font Awesome?") | |
gem 'font-awesome-rails' | |
run "echo '@import \"font-awesome\";' >> app/assets/stylesheets/application.css.scss" | |
end | |
# Ignore rails doc files, Vim/Emacs swap files, .DS_Store, and more | |
# =================================================== | |
run "cat << EOF >> .gitignore | |
/.bundle | |
/db/*.sqlite3 | |
/db/*.sqlite3-journal | |
/log/*.log | |
/tmp | |
database.yml | |
doc/ | |
*.swp | |
*~ | |
.project | |
.idea | |
.secret | |
.DS_Store | |
config/secrets.yml | |
/resources | |
.rspec | |
# Ignore uploaded pictures | |
/public/uploads/ | |
/public/dev-assets/ | |
EOF" | |
# Git: Initialize | |
# ================================================== | |
git :init | |
git add: "." | |
git commit: %Q{ -m 'Initial commit' } | |
if yes?("Initialize GitHub repository?") | |
git_uri = `git config remote.origin.url`.strip | |
unless git_uri.size == 0 | |
say "Repository already exists:" | |
say "#{git_uri}" | |
else | |
username = ask "What is your GitHub username?" | |
run "curl -u #{username} -d '{\"name\":\"#{app_name}\"}' https://api.github.com/user/repos" | |
git remote: %Q{ add origin [email protected]:#{username}/#{app_name}.git } | |
git push: %Q{ origin master } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment