Showing preview only (592K chars total). Download the full file or copy to clipboard to get everything.
Repository: RailsApps/rails3-application-templates
Branch: master
Commit: 5822198db57c
Files: 86
Total size: 559.3 KB
Directory structure:
gitextract_6n8lovbq/
├── .gitignore
├── README
├── README.textile
├── files/
│ ├── devise-views-haml/
│ │ └── app/
│ │ └── views/
│ │ └── devise/
│ │ ├── _links.erb
│ │ ├── registrations/
│ │ │ ├── edit.html.haml
│ │ │ └── new.html.haml
│ │ └── shared/
│ │ └── _links.html.haml
│ ├── gitignore.txt
│ ├── humans.txt
│ ├── navigation/
│ │ ├── devise/
│ │ │ ├── _navigation.html.erb
│ │ │ ├── _navigation.html.haml
│ │ │ └── authorization/
│ │ │ ├── _navigation.html.erb
│ │ │ └── _navigation.html.haml
│ │ ├── none/
│ │ │ ├── _navigation.html.erb
│ │ │ └── _navigation.html.haml
│ │ ├── omniauth/
│ │ │ ├── _navigation.html.erb
│ │ │ └── _navigation.html.haml
│ │ └── subdomains/
│ │ ├── _navigation.html.erb
│ │ └── _navigation.html.haml
│ ├── sample_readme.textile
│ ├── sample_readme.txt
│ ├── simple/
│ │ ├── assets/
│ │ │ └── stylesheets/
│ │ │ └── application.css.scss
│ │ └── views/
│ │ └── layouts/
│ │ ├── _messages.html.erb
│ │ ├── _messages.html.haml
│ │ ├── application.html.erb
│ │ └── application.html.haml
│ ├── twitter-bootstrap/
│ │ ├── assets/
│ │ │ └── stylesheets/
│ │ │ └── application.css.scss
│ │ └── views/
│ │ └── layouts/
│ │ ├── _messages.html.erb
│ │ ├── _messages.html.haml
│ │ ├── application.html.erb
│ │ └── application.html.haml
│ └── views/
│ └── layouts/
│ ├── application.html.erb
│ └── application.html.haml
├── files-v2/
│ ├── .rvmrc
│ ├── README
│ ├── README.textile
│ ├── app/
│ │ ├── assets/
│ │ │ └── stylesheets/
│ │ │ ├── application-bootstrap.css.scss
│ │ │ └── application.css.scss
│ │ └── views/
│ │ ├── devise/
│ │ │ ├── registrations/
│ │ │ │ ├── edit.html.erb
│ │ │ │ ├── edit.html.haml
│ │ │ │ ├── new.html.erb
│ │ │ │ └── new.html.haml
│ │ │ └── shared/
│ │ │ ├── _links.html.erb
│ │ │ └── _links.html.haml
│ │ ├── home/
│ │ │ ├── index-subdomains_app.html.erb
│ │ │ ├── index-subdomains_app.html.haml
│ │ │ ├── index.html.erb
│ │ │ └── index.html.haml
│ │ ├── layouts/
│ │ │ ├── _messages-bootstrap.html.erb
│ │ │ ├── _messages-bootstrap.html.haml
│ │ │ ├── _messages.html.erb
│ │ │ ├── _messages.html.haml
│ │ │ ├── _navigation-cancan.html.erb
│ │ │ ├── _navigation-cancan.html.haml
│ │ │ ├── _navigation-devise.html.erb
│ │ │ ├── _navigation-devise.html.haml
│ │ │ ├── _navigation-omniauth.html.erb
│ │ │ ├── _navigation-omniauth.html.haml
│ │ │ ├── _navigation-subdomains_app.html.erb
│ │ │ ├── _navigation-subdomains_app.html.haml
│ │ │ ├── _navigation.html.erb
│ │ │ ├── _navigation.html.haml
│ │ │ ├── application-bootstrap.html.erb
│ │ │ ├── application-bootstrap.html.haml
│ │ │ ├── application.html.erb
│ │ │ └── application.html.haml
│ │ ├── profiles/
│ │ │ ├── show-subdomains_app.html.erb
│ │ │ └── show-subdomains_app.html.haml
│ │ └── users/
│ │ ├── edit-omniauth.html.erb
│ │ ├── edit-omniauth.html.haml
│ │ ├── index.html.erb
│ │ ├── index.html.haml
│ │ ├── show-subdomains_app.html.erb
│ │ ├── show-subdomains_app.html.haml
│ │ ├── show.html.erb
│ │ └── show.html.haml
│ ├── config/
│ │ ├── database-mysql.yml
│ │ └── database-postgresql.yml
│ └── public/
│ └── humans.txt
├── rails-prelaunch-signup-template.rb
├── rails3-bootstrap-devise-cancan-template.rb
├── rails3-devise-rspec-cucumber-template.rb
├── rails3-haml-html5-template.rb
├── rails3-mongoid-devise-template.rb
├── rails3-mongoid-omniauth-template.rb
└── rails3-subdomains-template.rb
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
.DS_Store
================================================
FILE: README
================================================
Rails3-Application-Templates
========================
You can use these templates to generate a Rails web application.
________________________
See the README file on GitHub
For more information, please see the updated README file on GitHub:
http://github.com/RailsApps/rails3-application-templates
________________________
MIT License
================================================
FILE: README.textile
================================================
h1. !http://railsapps.github.com/images/rails-36x36.jpg(Rails 3.2 Application Templates)! Rails 3.2 Application Templates
h3. These application templates are deprecated (no longer maintained).
h3. Use the "Rails Composer":http://railsapps.github.com/rails-composer/ tool instead. The Rails Composer tool creates the example applications for the RailsApps project. The tool gives you a Rails 3.2 starter app you can deploy in minutes.
h2. Dependencies
Before generating your application, you will need:
* The Ruby language (version 1.9.3)
* Rails 3.2
See "Installing Rails":http://railsapps.github.com/installing-rails.html for detailed instructions and advice.
h2. Creating a Starter App
To build a Rails application, run the command (where @myapp@ is the name of your application):
<pre>
$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
</pre>
You can use the @-T@ flag to skip Test::Unit files or the @-O@ flag to skip Active Record files:
<pre>
$ rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb -T -O
</pre>
h2. Application Template Default
The @rails new@ command creates a new Rails application. If you want to use a template for every Rails application you build, you can set options for the @rails new@ command in a *.railsrc* file in your home directory. Here's how to set up a *.railsrc* file to use a template when you create a new Rails application:
<pre>
# ~/.railsrc
-m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
</pre>
h2. Troubleshooting
Problems? Check the "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues.
You should review the article "Installing Rails":http://railsapps.github.com/installing-rails.html to make sure you've updated all the components that are required to run Rails successfully.
h4. Problems with "Certificate Verify Failed"
Are you getting an error "OpenSSL certificate verify failed" when you try to generate a new Rails app from an application template? See suggestions to resolve the error "Certificate Verify Failed":http://railsapps.github.com/openssl-certificate-verify-failed.html.
h4. Problems with "Segmentation Fault"
If you get a "segfault" when you try @rails new@, try removing and reinstalling rvm.
h2. Documentation and Support
The application templates are assembled from recipes supplied by the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem. See the rails_apps_composer project to understand how the application templates work.
h4. Customizing the Template
If you wish to change a template to generate an app with your own customized options, you can copy and edit the template file. However, it is better to use the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem to create a new application template. You'll find newer versions of the recipes that make up the application template. You may find issues have been identified and (perhaps) fixed. And it will be easier to maintain your application template if you work from the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem.
h4. Writing Recipes
To understand the code in these templates, take a look at "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions. Your recipes can use any methods provided by "Thor::Actions":http://rdoc.info/github/wycats/thor/master/Thor/Actions or "Rails::Generators::Actions":http://railsapi.com/doc/rails-v3.0.3/classes/Rails/Generators/Actions.html.
h4. About Rails Application Templates
"Cooking Up A Custom Rails 3 Template (11 Oct 2010) by Andrea Singh":http://blog.madebydna.com/all/code/2010/10/11/cooking-up-a-custom-rails3-template.html
"Rails Application Templates (16 Sept 2010) by Collin Schaafsma":http://quickleft.com/blog/rails-application-templates
"Application templates in Rails 3 (18 Sept 2009) by Ben Scofield":http://benscofield.com/2009/09/application-templates-in-rails-3/
"Railscasts: App Templates in Rails 2.3 (9 Feb 2009) by Ryan Bates":http://railscasts.com/episodes/148-app-templates-in-rails-2-3
"Rails templates (4 Dec 2008) by Pratik Naik":http://m.onkey.org/rails-templates
h4. Similar Projects
There are many similar projects:
* "Rails application template projects":http://railsapps.github.com/rails-application-templates.html
* "Rails examples, tutorials, and starter apps":http://railsapps.github.com/rails-examples-tutorials.html.
h4. Issues
Please review "issues for the rails_apps_composer gem":https://github.com/RailsApps/rails_apps_composer/issues and submit any issues there.
h4. Where to Get Help
Your best source for help with problems is "Stack Overflow":http://stackoverflow.com/questions/tagged/ruby-on-rails-3. Your issue may have been encountered and addressed by others.
You can also try "Rails Hotline":http://www.railshotline.com/, a free telephone hotline for Rails help staffed by volunteers.
h2. Contributing
Please make changes to the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem rather than changing the application templates.
h2. Credits
Daniel Kehoe initiated the "RailsApps project":https://github.com/RailsApps and created the Rails Composer application template.
Is it useful to you? Follow the project on Twitter:
"@rails_apps":http://twitter.com/rails_apps
and tweet some praise. I'd love to know you were helped out by what I've put together.
h2. License
"MIT License":http://www.opensource.org/licenses/mit-license
Copyright 2012 Daniel Kehoe
h2. Useful Links
|_. Getting Started |_. Articles |_. Tutorials |
| "Rails Tutorial":https://tutorials.railsapps.org/rails-tutorial (recommendations) | "Heroku and Rails":http://railsapps.github.com/rails-heroku-tutorial.html | "Devise with CanCan and Twitter Bootstrap":https://tutorials.railsapps.org/rails3-bootstrap-devise-cancan |
| "Rails":http://railsapps.github.com/rails.html (resources)| "Twitter Bootstrap and Rails":http://railsapps.github.com/twitter-bootstrap-rails.html | "Rails Membership Site with Stripe":https://tutorials.railsapps.org/rails-stripe-membership-saas |
| "Installing Rails":http://railsapps.github.com/installing-rails.html | "JavaScript and Rails":http://railsapps.github.com/rails-javascript-include-external.html | "Rails Subscription Site with Recurly":https://tutorials.railsapps.org/rails-recurly-subscription-saas |
| "Updating Rails":http://railsapps.github.com/updating-rails.html | "Rails Environment Variables":http://railsapps.github.com/rails-environment-variables.html | "Startup Prelaunch Signup Application":http://railsapps.github.com/tutorial-rails-prelaunch-signup.html |
| "Rails Composer":http://railsapps.github.com/rails-composer/ | "Git and GitHub with Rails":http://railsapps.github.com/rails-git.html | "Devise with RSpec and Cucumber":http://railsapps.github.com/tutorial-rails-devise-rspec-cucumber.html |
| "Rails Examples":http://railsapps.github.com/ | "Send Email with Rails":http://railsapps.github.com/rails-send-email.html | "Devise with Mongoid":http://railsapps.github.com/tutorial-rails-mongoid-devise.html |
| "Rails Starter Apps":http://railsapps.github.com/rails-examples-tutorials.html | "Haml and Rails":http://railsapps.github.com/rails-haml.html | "OmniAuth with Mongoid":http://railsapps.github.com/tutorial-rails-mongoid-omniauth.html |
| | "Rails Application Layout":http://railsapps.github.com/rails-default-application-layout.html | "Subdomains with Devise":http://railsapps.github.com/tutorial-rails-subdomains.html |
| | "HTML5 Boilerplate for Rails":http://railsapps.github.com/rails-html5-boilerplate.html | |
| | "Example Gemfiles for Rails":http://railsapps.github.com/rails-3-2-example-gemfile.html | |
| | "Rails Application Templates":http://railsapps.github.com/rails-application-templates.html | |
!https://cruel-carlota.pagodabox.com/face2018e437828af58da43b847d6178(githalytics.com alpha)!
================================================
FILE: files/devise-views-haml/app/views/devise/_links.erb
================================================
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
================================================
FILE: files/devise-views-haml/app/views/devise/registrations/edit.html.haml
================================================
%h2
Edit #{resource_name.to_s.humanize}
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
= devise_error_messages!
%p
= f.label :name
%br/
= f.text_field :name
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%i (leave blank if you don't want to change it)
%br/
= f.password_field :password, :autocomplete => "off"
%div
= f.label :password_confirmation
%br/
= f.password_field :password_confirmation
%div
= f.label :current_password
%i (we need your current password to confirm your changes)
%br/
= f.password_field :current_password
%div= f.submit "Update"
%h3 Cancel my account
%p
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}.
= link_to "Back", :back
================================================
FILE: files/devise-views-haml/app/views/devise/registrations/new.html.haml
================================================
%h2 Sign up
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= devise_error_messages!
%p
= f.label :name
%br/
= f.text_field :name
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%br/
= f.password_field :password
%div
= f.label :password_confirmation
%br/
= f.password_field :password_confirmation
%div= f.submit "Sign up"
= render :partial => "devise/shared/links"
================================================
FILE: files/devise-views-haml/app/views/devise/shared/_links.html.haml
================================================
- if controller_name != 'sessions'
= link_to "Sign in", new_session_path(resource_name)
%br/
- if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Sign up", new_registration_path(resource_name)
%br/
- if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to "Forgot your password?", new_password_path(resource_name)
%br/
- if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
%br/
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
%br/
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
%br/
================================================
FILE: files/gitignore.txt
================================================
#----------------------------------------------------------------------------
# Ignore these files when commiting to a git repository.
#
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# The original version of this file is found here:
# https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt
#
# Corrections? Improvements? Create a GitHub issue:
# http://github.com/RailsApps/rails3-application-templates/issues
#----------------------------------------------------------------------------
# bundler state
/.bundle
/vendor/bundle/
# minimal Rails specific artifacts
db/*.sqlite3
/log/*
/tmp/*
# various artifacts
**.war
*.rbc
*.sassc
.rspec
.redcar/
.sass-cache
/config/config.yml
/config/database.yml
/coverage.data
/coverage/
/db/*.javadb/
/db/*.sqlite3
/doc/api/
/doc/app/
/doc/features.html
/doc/specs.html
/public/cache
/public/stylesheets/compiled
/public/system/*
/spec/tmp/*
/cache
/capybara*
/capybara-*.html
/gems
/spec/requests
/spec/routing
/spec/views
/specifications
rerun.txt
pickle-email-*.html
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
#
# Here are some files you may want to ignore globally:
# scm revert files
**.orig
# Mac finder artifacts
.DS_Store
# Netbeans project directory
/nbproject/
# RubyMine project files
.idea
# Textmate project files
/*.tmproj
# vim artifacts
**.swp
================================================
FILE: files/humans.txt
================================================
/* the humans responsible & colophon */
/* humanstxt.org */
/* TEAM */
<your title>: <your name>
Site:
Twitter:
Location:
/* THANKS */
Daniel Kehoe (@rails_apps) for the RailsApps project
/* SITE */
Standards: HTML5, CSS3
Components: jQuery
Software: Ruby on Rails
/* GENERATED BY */
RailsApps application template: http://railsapps.github.com/
================================================
FILE: files/navigation/devise/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_path %>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_path %>
</li>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_path %>
</li>
<% end %>
</ul>
================================================
FILE: files/navigation/devise/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_path, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_path)
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_path)
- else
%li
= link_to('Sign up', new_user_registration_path)
================================================
FILE: files/navigation/devise/authorization/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_path %>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_path %>
</li>
<% if current_user.has_role? :admin %>
<li>
<%= link_to 'Admin', users_path %>
</li>
<% end %>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_path %>
</li>
<% end %>
</ul>
================================================
FILE: files/navigation/devise/authorization/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_path, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_path)
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_path)
- if current_user.has_role? :admin
%li
= link_to('Admin', users_path)
- else
%li
= link_to('Sign up', new_user_registration_path)
================================================
FILE: files/navigation/none/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
================================================
FILE: files/navigation/none/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
================================================
FILE: files/navigation/omniauth/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
Logged in as <%= current_user.name %>
</li>
<li>
<%= link_to 'Logout', signout_path %>
</li>
<% else %>
<li>
<%= link_to 'Login', signin_path %>
</li>
<% end %>
</ul>
================================================
FILE: files/navigation/omniauth/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
Logged in as #{current_user.name}
%li
= link_to('Logout', signout_path)
- else
%li
= link_to('Login', signin_path)
================================================
FILE: files/navigation/subdomains/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<li>
<%= link_to 'Main', root_url(:host => request.domain) %>
</li>
<% if request.subdomain.present? && request.subdomain != "www" %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_url %>
</li>
<li>
<%= link_to 'Logout', destroy_user_session_url, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_url %>
</li>
<% end %>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_url(:host => request.domain) %>
</li>
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_url, :method=>'delete' %>
</li>
<% end %>
<% end %>
</ul>
================================================
FILE: files/navigation/subdomains/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
%li
= link_to 'Main', root_url(:host => request.domain)
- if request.subdomain.present? && request.subdomain != "www"
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_url)
%li
= link_to('Logout', destroy_user_session_url, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_url)
- else
%li
= link_to('Sign up', new_user_registration_url(:host => request.domain))
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_url, :method=>'delete')
================================================
FILE: files/sample_readme.textile
================================================
h1. App_Name
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. More Information
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Required Gems
This application requires this gem:
* "rails":http://rubygems.org/gems/rails
h2. Dependencies
To use this application, you will need:
* The Ruby language (version 1.8.7 or 1.9.2)
* Rails (version 3.0.4 or newer)
h2. Installing the Application
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Getting Started
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Documentation and Support
This is the only documentation.
h4. Issues
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Similar Projects
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Contributing
If you make improvements to this application, please share with others.
* Fork the project on GitHub.
* Make your feature addition or bug fix.
* Commit with Git.
* Send the author a pull request.
If you add functionality to this application, create an alternative implementation, or build an application that is similar, please contact me and I'll add a note to the README so that others can find your work.
h2. Credits
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. License
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
================================================
FILE: files/sample_readme.txt
================================================
App_Name
========================
________________________
License
================================================
FILE: files/simple/assets/stylesheets/application.css.scss
================================================
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
.brand {
float: left;
padding-right: 8px;
}
ul.nav {
list-style: none;
margin: 0 0 2em;
padding: 0;
}
ul.nav li {
display: inline;
}
#flash_notice, #flash_alert {
padding: 5px 8px;
margin: 10px 0;
}
#flash_notice {
background-color: #CFC;
border: solid 1px #6C6;
}
#flash_alert {
background-color: #FCC;
border: solid 1px #C66;
}
================================================
FILE: files/simple/views/layouts/_messages.html.erb
================================================
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
<% end %>
================================================
FILE: files/simple/views/layouts/_messages.html.haml
================================================
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
================================================
FILE: files/simple/views/layouts/application.html.erb
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App_Name</title>
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="container" class="container">
<header>
<%= render 'layouts/navigation' %>
<%= render 'layouts/messages' %>
</header>
<div id="main" role="main">
<%= yield %>
</div>
<footer>
</footer>
</div> <!--! end of #container -->
</body>
</html>
================================================
FILE: files/simple/views/layouts/application.html.haml
================================================
!!!
%html
%head
%title App_Name
%meta{:charset => "utf-8"}
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
= stylesheet_link_tag :application, :media => "all"
= javascript_include_tag :application
= csrf_meta_tags
%body
#container.container
%header
= render 'layouts/navigation'
= render 'layouts/messages'
#main{:role => "main"}
= yield
%footer
================================================
FILE: files/twitter-bootstrap/assets/stylesheets/application.css.scss
================================================
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
.content {
background-color: #eee;
padding: 20px;
margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */
-webkit-border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
================================================
FILE: files/twitter-bootstrap/views/layouts/_messages.html.erb
================================================
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<a class="close" data-dismiss="alert">×</a>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
</div>
<% end %>
================================================
FILE: files/twitter-bootstrap/views/layouts/_messages.html.haml
================================================
- flash.each do |name, msg|
%div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
%a.close{"data-dismiss" => "alert"} ×
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
================================================
FILE: files/twitter-bootstrap/views/layouts/application.html.erb
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "App_Name" %></title>
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= yield(:head) %>
</head>
<body>
<header class="navbar navbar-fixed-top">
<nav class="navbar-inner">
<div class="container">
<%= render 'layouts/navigation' %>
</div>
</nav>
</header>
<div id="main" role="main">
<div class="container">
<div class="content">
<div class="row">
<div class="span12">
<%= render 'layouts/messages' %>
<%= yield %>
</div>
</div>
<footer>
</footer>
</div>
</div> <!--! end of .container -->
</div> <!--! end of #main -->
</body>
</html>
================================================
FILE: files/twitter-bootstrap/views/layouts/application.html.haml
================================================
!!!
%html
%head
%meta{:charset => "utf-8"}
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%title= content_for?(:title) ? yield(:title) : "App_Name"
%meta{:content => "", :name => "description"}
%meta{:content => "", :name => "author"}
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
= yield(:head)
%body
%header.navbar.navbar-fixed-top
%nav.navbar-inner
.container
= render 'layouts/navigation'
#main{:role => "main"}
.container
.content
.row
.span12
= render 'layouts/messages'
= yield
%footer
================================================
FILE: files/views/layouts/application.html.erb
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App_Name</title>
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="container" class="container">
<header>
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
<%- end -%>
</header>
<div id="main" role="main">
<%= yield %>
</div>
<footer>
</footer>
</div> <!--! end of #container -->
</body>
</html>
================================================
FILE: files/views/layouts/application.html.haml
================================================
!!!
%html
%head
%title App_Name
%meta{:charset => "utf-8"}
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
= stylesheet_link_tag :application, :media => "all"
= javascript_include_tag :application
= csrf_meta_tags
%body
#container.container
%header
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
#main{:role => "main"}
= yield
%footer
================================================
FILE: files-v2/.rvmrc
================================================
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo "rvm use 1.9.3" > .rvmrc
environment_id="ruby-1.9.3@App_Name"
# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version="1.14.2 (latest)" # 1.10.1 seams as a safe start
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
# return 1
# }
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
# If you use bundler, this might be useful to you:
# if [[ -s Gemfile ]] && {
# ! builtin command -v bundle >/dev/null ||
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
# }
# then
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
# gem install bundler
# fi
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
# then
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
# fi
================================================
FILE: files-v2/README
================================================
App_Name
========================
This application was generated with the rails_apps_composer gem:
https://github.com/RailsApps/rails_apps_composer
provided by the RailsApps Project:
http://railsapps.github.com/
________________________
Recipes:
RECIPES
Preferences:
PREFERENCES
________________________
License
================================================
FILE: files-v2/README.textile
================================================
h1. App_Name
This application was generated with the "rails_apps_composer":https://github.com/RailsApps/rails_apps_composer gem provided by the "RailsApps Project":http://railsapps.github.com/.
h2. Diagnostics
This application was built with recipes that are known to work together.
This application was built with preferences that are known to work together.
If the application doesn't work as expected, please "report an issue":https://github.com/RailsApps/rails_apps_composer/issues and include these diagnostics:
We'd also like to know if you've found combinations of recipes or preferences that do work together.
Recipes:
RECIPES
Preferences:
PREFERENCES
h2. Ruby on Rails
This application requires:
* Ruby
* Rails
Learn more about "Installing Rails":http://railsapps.github.com/installing-rails.html.
h2. Database
This application uses SQLite with ActiveRecord.
h2. Development
* Template Engine: ERB
* Testing Framework: Test::Unit
* Front-end Framework: None
* Form Builder: None
* Authentication: None
* Authorization: None
h2. Email
The application is configured to send email using a Gmail account.
h2. Getting Started
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Documentation and Support
This is the only documentation.
h4. Issues
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Similar Projects
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. Contributing
If you make improvements to this application, please share with others.
* Fork the project on GitHub.
* Make your feature addition or bug fix.
* Commit with Git.
* Send the author a pull request.
If you add functionality to this application, create an alternative implementation, or build an application that is similar, please contact me and I'll add a note to the README so that others can find your work.
h2. Credits
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
h2. License
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
================================================
FILE: files-v2/app/assets/stylesheets/application-bootstrap.css.scss
================================================
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
.content {
background-color: #eee;
padding: 20px;
margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */
-webkit-border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
================================================
FILE: files-v2/app/assets/stylesheets/application.css.scss
================================================
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/
.brand {
float: left;
padding-right: 8px;
}
ul.nav {
list-style: none;
margin: 0 0 2em;
padding: 0;
}
ul.nav li {
display: inline;
}
#flash_notice, #flash_alert {
padding: 5px 8px;
margin: 10px 0;
}
#flash_notice {
background-color: #CFC;
border: solid 1px #6C6;
}
#flash_alert {
background-color: #FCC;
border: solid 1px #C66;
}
================================================
FILE: files-v2/app/views/devise/registrations/edit.html.erb
================================================
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :name %><br />
<%= f.text_field :name %></p>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
<%= link_to "Back", :back %>
================================================
FILE: files-v2/app/views/devise/registrations/edit.html.haml
================================================
%h2
Edit #{resource_name.to_s.humanize}
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
= devise_error_messages!
%p
= f.label :name
%br/
= f.text_field :name
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%i (leave blank if you don't want to change it)
%br/
= f.password_field :password, :autocomplete => "off"
%div
= f.label :password_confirmation
%br/
= f.password_field :password_confirmation
%div
= f.label :current_password
%i (we need your current password to confirm your changes)
%br/
= f.password_field :current_password
%div= f.submit "Update"
%h3 Cancel my account
%p
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}.
= link_to "Back", :back
================================================
FILE: files-v2/app/views/devise/registrations/new.html.erb
================================================
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :name %><br />
<%= f.text_field :name %></p>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render "devise/shared/links" %>
================================================
FILE: files-v2/app/views/devise/registrations/new.html.haml
================================================
%h2 Sign up
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= devise_error_messages!
%p
= f.label :name
%br/
= f.text_field :name
%div
= f.label :email
%br/
= f.email_field :email
%div
= f.label :password
%br/
= f.password_field :password
%div
= f.label :password_confirmation
%br/
= f.password_field :password_confirmation
%div= f.submit "Sign up"
= render :partial => "devise/shared/links"
================================================
FILE: files-v2/app/views/devise/shared/_links.html.erb
================================================
<%- if controller_name != 'sessions' %>
<%= link_to "Sign in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
================================================
FILE: files-v2/app/views/devise/shared/_links.html.haml
================================================
- if controller_name != 'sessions'
= link_to "Sign in", new_session_path(resource_name)
%br/
- if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Sign up", new_registration_path(resource_name)
%br/
- if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to "Forgot your password?", new_password_path(resource_name)
%br/
- if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
%br/
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
%br/
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
%br/
================================================
FILE: files-v2/app/views/home/index-subdomains_app.html.erb
================================================
<h3>Home</h3>
<% @users.each do |user| %>
<p><%= #{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)} %></p>
<% end %>
================================================
FILE: files-v2/app/views/home/index-subdomains_app.html.haml
================================================
%h3 Home
- @users.each do |user|
%br/
#{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:subdomain => user.name)}
================================================
FILE: files-v2/app/views/home/index.html.erb
================================================
<h3>Home</h3>
<% @users.each do |user| %>
<p>User: <%=link_to user.name, user %></p>
<% end %>
================================================
FILE: files-v2/app/views/home/index.html.haml
================================================
%h3 Home
- @users.each do |user|
%p
User: #{link_to user.name, user}
================================================
FILE: files-v2/app/views/layouts/_messages-bootstrap.html.erb
================================================
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<a class="close" data-dismiss="alert">×</a>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
</div>
<% end %>
================================================
FILE: files-v2/app/views/layouts/_messages-bootstrap.html.haml
================================================
- flash.each do |name, msg|
%div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
%a.close{"data-dismiss" => "alert"} ×
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
================================================
FILE: files-v2/app/views/layouts/_messages.html.erb
================================================
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
<% end %>
================================================
FILE: files-v2/app/views/layouts/_messages.html.haml
================================================
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String)
================================================
FILE: files-v2/app/views/layouts/_navigation-cancan.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_path %>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_path %>
</li>
<% if current_user.has_role? :admin %>
<li>
<%= link_to 'Admin', users_path %>
</li>
<% end %>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_path %>
</li>
<% end %>
</ul>
================================================
FILE: files-v2/app/views/layouts/_navigation-cancan.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_path, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_path)
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_path)
- if current_user.has_role? :admin
%li
= link_to('Admin', users_path)
- else
%li
= link_to('Sign up', new_user_registration_path)
================================================
FILE: files-v2/app/views/layouts/_navigation-devise.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_path, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_path %>
</li>
<% end %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_path %>
</li>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_path %>
</li>
<% end %>
</ul>
================================================
FILE: files-v2/app/views/layouts/_navigation-devise.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_path, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_path)
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_path)
- else
%li
= link_to('Sign up', new_user_registration_path)
================================================
FILE: files-v2/app/views/layouts/_navigation-omniauth.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<% if user_signed_in? %>
<li>
Logged in as <%= current_user.name %>
</li>
<li>
<%= link_to 'Logout', signout_path %>
</li>
<% else %>
<li>
<%= link_to 'Login', signin_path %>
</li>
<% end %>
</ul>
================================================
FILE: files-v2/app/views/layouts/_navigation-omniauth.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
- if user_signed_in?
%li
Logged in as #{current_user.name}
%li
= link_to('Logout', signout_path)
- else
%li
= link_to('Login', signin_path)
================================================
FILE: files-v2/app/views/layouts/_navigation-subdomains_app.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
<ul class="nav">
<li>
<%= link_to 'Main', root_url(:host => request.domain) %>
</li>
<% if request.subdomain.present? && request.subdomain != "www" %>
<% if user_signed_in? %>
<li>
<%= link_to 'Edit account', edit_user_registration_url %>
</li>
<li>
<%= link_to 'Logout', destroy_user_session_url, :method=>'delete' %>
</li>
<% else %>
<li>
<%= link_to 'Login', new_user_session_url %>
</li>
<% end %>
<% else %>
<li>
<%= link_to 'Sign up', new_user_registration_url(:host => request.domain) %>
</li>
<% if user_signed_in? %>
<li>
<%= link_to 'Logout', destroy_user_session_url, :method=>'delete' %>
</li>
<% end %>
<% end %>
</ul>
================================================
FILE: files-v2/app/views/layouts/_navigation-subdomains_app.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
%ul.nav
%li
= link_to 'Main', root_url(:host => request.domain)
- if request.subdomain.present? && request.subdomain != "www"
- if user_signed_in?
%li
= link_to('Edit account', edit_user_registration_url)
%li
= link_to('Logout', destroy_user_session_url, :method=>'delete')
- else
%li
= link_to('Login', new_user_session_url)
- else
%li
= link_to('Sign up', new_user_registration_url(:host => request.domain))
- if user_signed_in?
%li
= link_to('Logout', destroy_user_session_url, :method=>'delete')
================================================
FILE: files-v2/app/views/layouts/_navigation.html.erb
================================================
<%= link_to "App_Name", root_path, :class => 'brand' %>
================================================
FILE: files-v2/app/views/layouts/_navigation.html.haml
================================================
= link_to "App_Name", root_path, :class => 'brand'
================================================
FILE: files-v2/app/views/layouts/application-bootstrap.html.erb
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "App_Name" %></title>
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= yield(:head) %>
</head>
<body>
<header class="navbar navbar-fixed-top">
<nav class="navbar-inner">
<div class="container">
<%= render 'layouts/navigation' %>
</div>
</nav>
</header>
<div id="main" role="main">
<div class="container">
<div class="content">
<div class="row">
<div class="span12">
<%= render 'layouts/messages' %>
<%= yield %>
</div>
</div>
<footer>
</footer>
</div>
</div> <!--! end of .container -->
</div> <!--! end of #main -->
</body>
</html>
================================================
FILE: files-v2/app/views/layouts/application-bootstrap.html.haml
================================================
!!!
%html
%head
%meta{:charset => "utf-8"}
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%title= content_for?(:title) ? yield(:title) : "App_Name"
%meta{:content => "", :name => "description"}
%meta{:content => "", :name => "author"}
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
= yield(:head)
%body
%header.navbar.navbar-fixed-top
%nav.navbar-inner
.container
= render 'layouts/navigation'
#main{:role => "main"}
.container
.content
.row
.span12
= render 'layouts/messages'
= yield
%footer
================================================
FILE: files-v2/app/views/layouts/application.html.erb
================================================
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App_Name</title>
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="container" class="container">
<header>
<%= render 'layouts/navigation' %>
<%= render 'layouts/messages' %>
</header>
<div id="main" role="main">
<%= yield %>
</div>
<footer>
</footer>
</div> <!--! end of #container -->
</body>
</html>
================================================
FILE: files-v2/app/views/layouts/application.html.haml
================================================
!!!
%html
%head
%title App_Name
%meta{:charset => "utf-8"}
%meta{"http-equiv" => "X-UA-Compatible", :content => "IE=edge,chrome=1"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
= stylesheet_link_tag :application, :media => "all"
= javascript_include_tag :application
= csrf_meta_tags
%body
#container.container
%header
= render 'layouts/navigation'
= render 'layouts/messages'
#main{:role => "main"}
= yield
%footer
================================================
FILE: files-v2/app/views/profiles/show-subdomains_app.html.erb
================================================
<h1>Profile</h1>
<h3><%= @user.name %></h3>
<h3><%= @user.email %></h3>
================================================
FILE: files-v2/app/views/profiles/show-subdomains_app.html.haml
================================================
%h1 Profile
%h3= @user.name
%h3= @user.email
================================================
FILE: files-v2/app/views/users/edit-omniauth.html.erb
================================================
<%= form_for(@user) do |f| %>
<%= f.label :email %>
<%= f.text_field :email %>
<br />
<%= f.submit "Sign in" %>
<% end %>
================================================
FILE: files-v2/app/views/users/edit-omniauth.html.haml
================================================
= form_for(@user) do |f|
= f.label :email
= f.text_field :email
%br/
= f.submit "Sign in"
================================================
FILE: files-v2/app/views/users/index.html.erb
================================================
<h3>Users</h3>
<ul class="users">
<% @users.each do |user| %>
<li>
<%= link_to user.name, user %> signed up <%= user.created_at.to_date %>
</li>
<% end %>
</ul>
================================================
FILE: files-v2/app/views/users/index.html.haml
================================================
%h3 Users
%ul.users
- @users.each do |user|
%li
= link_to user.name, user
signed up #{user.created_at.to_date}
================================================
FILE: files-v2/app/views/users/show-subdomains_app.html.erb
================================================
<p>User: <%= @user.name %></p>
<p>Email: <%= @user.email if @user.email %></p>
<p>Profile: <%= #{link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name)} %></p>
================================================
FILE: files-v2/app/views/users/show-subdomains_app.html.haml
================================================
%p
User: #{@user.name}
%p
Email: #{@user.email if @user.email}
%p
Profile: #{link_to root_url(:subdomain => @user.name), root_url(:subdomain => @user.name)}
================================================
FILE: files-v2/app/views/users/show.html.erb
================================================
<h3>User</h3>
<p>User: <%= @user.name %></p>
<p>Email: <%= @user.email if @user.email %></p>
================================================
FILE: files-v2/app/views/users/show.html.haml
================================================
%h3 User
%p
User: #{@user.name}
%p
Email: #{@user.email if @user.email}
================================================
FILE: files-v2/config/database-mysql.yml
================================================
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_development
pool: 5
username: root
password:
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_test
pool: 5
username: root
password:
host: localhost
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: myapp_production
pool: 5
username: root
password:
host: localhost
================================================
FILE: files-v2/config/database-postgresql.yml
================================================
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: myapp_test
pool: 5
username: myapp
password:
production:
adapter: postgresql
encoding: unicode
database: myapp_production
pool: 5
username: myapp
password:
================================================
FILE: files-v2/public/humans.txt
================================================
/* the humans responsible & colophon */
/* humanstxt.org */
/* TEAM */
<your title>: <your name>
Site:
Twitter:
Location:
/* THANKS */
Daniel Kehoe (@rails_apps) for the RailsApps project
/* SITE */
Standards: HTML5, CSS3
Components: jQuery
Software: Ruby on Rails
/* GENERATED BY */
RailsApps application template: http://railsapps.github.com/
================================================
FILE: rails-prelaunch-signup-template.rb
================================================
# >---------------------------------------------------------------------------<
#
# _____ _ _
# | __ \ (_) | /\
# | |__) |__ _ _| |___ / \ _ __ _ __ ___
# | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __|
# | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \
# |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/
# | | | |
# |_| |_|
#
# Application template generated by the rails_apps_composer gem.
# Restrain your impulse to make changes to this file; instead,
# make changes to the recipes in the rails_apps_composer gem.
#
# For more information, see:
# https://github.com/RailsApps/rails_apps_composer/
#
# Thank you to Michael Bleigh for leading the way with the RailsWizard gem.
#
# >---------------------------------------------------------------------------<
# >----------------------------[ Initial Setup ]------------------------------<
run 'bundle update'
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
end
RUBY
@recipes = ["core", "git", "railsapps", "setup", "readme", "gems", "testing", "email", "models", "controllers", "views", "routes", "frontend", "init", "prelaunch", "saas", "extras"]
@prefs = {:railsapps=>"rails-prelaunch-signup", :dev_webserver=>"webrick", :prod_webserver=>"same", :templates=>"erb", :ban_spiders=>true, :jsruntime=>false, :rvmrc=>true, :github=>false, :quiet_assets=>true}
@gems = []
@diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "saas", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "saas", "setup", "testing", "views"]]
@diagnostics_prefs = [{:railsapps=>"rails-stripe-membership-saas", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails-stripe-membership-saas", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"mandrill", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails-prelaunch-signup", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"mandrill", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails3-bootstrap-devise-cancan", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails3-devise-rspec-cucumber", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-devise", :database=>"mongodb", :orm=>"mongoid", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-omniauth", :database=>"mongodb", :orm=>"mongoid", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-subdomains", :database=>"mongodb", :orm=>"mongoid", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"subdomains_app", :form_builder=>"none"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"rspec-capybara", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"invitable", :authorization=>"cancan", :form_builder=>"simple_form", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"test_unit", :integration=>"none", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"less", :email=>"sendgrid", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}]
diagnostics = {}
def recipes; @recipes end
def recipe?(name); @recipes.include?(name) end
def prefs; @prefs end
def prefer(key, value); @prefs[key].eql? value end
def gems; @gems end
def diagnostics_recipes; @diagnostics_recipes end
def diagnostics_prefs; @diagnostics_prefs end
def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
def ask_wizard(question)
ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m"
end
def yes_wizard?(question)
answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
case answer.downcase
when "yes", "y"
true
when "no", "n"
false
else
yes_wizard?(question)
end
end
def no_wizard?(question); !yes_wizard?(question) end
def multiple_choice(question, choices)
say_custom('question', question)
values = {}
choices.each_with_index do |choice,i|
values[(i + 1).to_s] = choice[1]
say_custom( (i + 1).to_s + ')', choice[0] )
end
answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
values[answer]
end
@current_recipe = nil
@configs = {}
@after_blocks = []
def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
@after_everything_blocks = []
def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
@before_configs = {}
def before_config(&block); @before_configs[@current_recipe] = block; end
def copy_from(source, destination)
begin
remove_file destination
get source, destination
rescue OpenURI::HTTPError
say_wizard "Unable to obtain #{source}"
end
end
def copy_from_repo(filename, opts = {})
repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/'
repo = opts[:repo] unless opts[:repo].nil?
if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs])
return
end
source_filename = filename
destination_filename = filename
unless opts[:prefs].nil?
if filename.include? opts[:prefs]
destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '')
end
end
if (prefer :templates, 'haml') && (filename.include? 'views')
remove_file destination_filename
destination_filename = destination_filename.gsub(/.erb/, '.haml')
end
if (prefer :templates, 'slim') && (filename.include? 'views')
remove_file destination_filename
destination_filename = destination_filename.gsub(/.erb/, '.slim')
end
begin
remove_file destination_filename
if (prefer :templates, 'haml') && (filename.include? 'views')
create_file destination_filename, html_to_haml(repo + source_filename)
elsif (prefer :templates, 'slim') && (filename.include? 'views')
create_file destination_filename, html_to_slim(repo + source_filename)
else
get repo + source_filename, destination_filename
end
rescue OpenURI::HTTPError
say_wizard "Unable to obtain #{source_filename} from the repo #{repo}"
end
end
def html_to_haml(source)
html = open(source) {|input| input.binmode.read }
Haml::HTML.new(html, :erb => true, :xhtml => true).render
end
def html_to_slim(source)
html = open(source) {|input| input.binmode.read }
haml = Haml::HTML.new(html, :erb => true, :xhtml => true).render
Haml2Slim.convert!(haml)
end
if diagnostics_recipes.sort.include? recipes.sort
diagnostics[:recipes] = 'success'
say_wizard("WOOT! The recipes you've selected are known to work together.")
else
diagnostics[:recipes] = 'fail'
say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m")
say_wizard("Help us out by reporting whether this combination works or fails.")
say_wizard("Please open an issue for rails_apps_composer on GitHub.")
say_wizard("Your new application will contain diagnostics in its README file.")
say_wizard("Continuing...")
end
# this application template only supports Rails version 3.1 and newer
case Rails::VERSION::MAJOR.to_s
when "3"
case Rails::VERSION::MINOR.to_s
when "0"
say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
end
else
say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
end
say_wizard "Using rails_apps_composer recipes to generate an application."
# >---------------------------[ Autoload Modules/Classes ]-----------------------------<
inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY'
config.autoload_paths += %W(#{config.root}/lib)
RUBY
end
# >---------------------------------[ Recipes ]----------------------------------<
# >---------------------------------[ core ]----------------------------------<
@current_recipe = "core"
@before_configs["core"].call if @before_configs["core"]
say_recipe 'core'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/core.rb
## Git
say_wizard "selected all core recipes"
# >----------------------------------[ git ]----------------------------------<
@current_recipe = "git"
@before_configs["git"].call if @before_configs["git"]
say_recipe 'git'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb
## Git
say_wizard "initialize git"
prefs[:git] = true unless prefs.has_key? :git
if prefer :git, true
copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
git :init
git :add => '-A'
git :commit => '-qm "rails_apps_composer: initial commit"'
end
# >-------------------------------[ railsapps ]-------------------------------<
@current_recipe = "railsapps"
@before_configs["railsapps"].call if @before_configs["railsapps"]
say_recipe 'railsapps'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/railsapps.rb
prefs[:railsapps] = multiple_choice "Install an example application?",
[["I want to build my own application", "none"],
["rails-stripe-membership-saas", "rails-stripe-membership-saas"],
["rails-prelaunch-signup", "rails-prelaunch-signup"],
["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"],
["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"],
["rails3-mongoid-devise", "rails3-mongoid-devise"],
["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps
case prefs[:railsapps]
when 'rails-stripe-membership-saas'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'bootstrap'
prefs[:bootstrap] = 'sass'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'cancan'
prefs[:starter_app] = 'admin_app'
prefs[:form_builder] = 'simple_form'
prefs[:quiet_assets] = true
when 'rails-prelaunch-signup'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'bootstrap'
prefs[:bootstrap] = 'sass'
prefs[:email] = 'mandrill'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'confirmable'
prefs[:authorization] = 'cancan'
prefs[:starter_app] = 'admin_app'
prefs[:form_builder] = 'simple_form'
prefs[:quiet_assets] = true
if prefer :git, true
prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?", [["wip (work-in-progress)", "wip"], ["master", "master"], ["prelaunch", "prelaunch"], ["staging", "staging"]]
if prefs[:prelaunch_branch] == 'master'
prefs[:main_branch] = multiple_choice "Git branch for the main app?", [["None", "none"], ["wip (work-in-progress)", "wip"], ["edge", "edge"]]
else
prefs[:main_branch] = 'master'
end
end
when 'rails3-bootstrap-devise-cancan'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'bootstrap'
prefs[:bootstrap] = 'sass'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'cancan'
prefs[:starter_app] = 'admin_app'
prefs[:form_builder] = 'simple_form'
prefs[:quiet_assets] = true
when 'rails3-devise-rspec-cucumber'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
when 'rails3-devise-rspec-cucumber-fabrication'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'fabrication'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
when 'rails3-mongoid-devise'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
when 'rails3-mongoid-omniauth'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'none'
prefs[:authentication] = 'omniauth'
prefs[:omniauth_provider] = 'twitter'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
when 'rails3-subdomains'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'subdomains_app'
prefs[:form_builder] = 'none'
prefs[:quiet_assets] = true
end
# >---------------------------------[ setup ]---------------------------------<
@current_recipe = "setup"
@before_configs["setup"].call if @before_configs["setup"]
say_recipe 'setup'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb
## Ruby on Rails
HOST_OS = RbConfig::CONFIG['host_os']
say_wizard "Your operating system is #{HOST_OS}."
say_wizard "You are using Ruby version #{RUBY_VERSION}."
say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
## Is sqlite3 in the Gemfile?
gemfile = File.read(destination_root() + '/Gemfile')
sqlite_detected = gemfile.include? 'sqlite3'
## Web Server
prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"],
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :dev_webserver
webserver = multiple_choice "Web server for production?", [["Same as development", "same"],
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :prod_webserver
if webserver == 'same'
case prefs[:dev_webserver]
when 'thin'
prefs[:prod_webserver] = 'thin'
when 'unicorn'
prefs[:prod_webserver] = 'unicorn'
when 'puma'
prefs[:prod_webserver] = 'puma'
end
else
prefs[:prod_webserver] = webserver
end
## Database Adapter
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database
case prefs[:database]
when 'mongodb'
unless sqlite_detected
prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm
else
say_wizard "WARNING! SQLite gem detected in the Gemfile"
say_wizard "If you wish to use MongoDB you must skip Active Record."
say_wizard "If using rails_apps_composer, choose 'skip Active Record'."
say_wizard "If using Rails Composer or an application template, use the '-O' flag as in 'rails new foo -O'."
prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]]
if prefer :fail, 'abort'
raise StandardError.new "SQLite detected in the Gemfile. Use '-O' or '--skip-activerecord' as in 'rails new foo -O' if you don't want ActiveRecord and SQLite"
end
end
end
## Template Engine
prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim (experimental)", "slim"]] unless prefs.has_key? :templates
## Testing Framework
if recipes.include? 'testing'
prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"], ["MiniTest", "minitest"]] unless prefs.has_key? :unit_test
prefs[:integration] = multiple_choice "Integration testing?", [["None", "none"], ["RSpec with Capybara", "rspec-capybara"],
["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"], ["MiniTest with Capybara", "minitest-capybara"]] unless prefs.has_key? :integration
prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"], ["Fabrication","fabrication"]] unless prefs.has_key? :fixtures
end
## Front-end Framework
if recipes.include? 'frontend'
prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], ["Twitter Bootstrap", "bootstrap"],
["Zurb Foundation", "foundation"], ["Skeleton", "skeleton"], ["Just normalize CSS for consistent styling", "normalize"]] unless prefs.has_key? :frontend
if prefer :frontend, 'bootstrap'
case HOST_OS
when /mswin|windows/i
prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap
else
prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Less)", "less"],
["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap
end
end
end
## Email
if recipes.include? 'email'
prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"],
["SendGrid","sendgrid"], ["Mandrill","mandrill"]] unless prefs.has_key? :email
else
prefs[:email] = 'none'
end
## Authentication and Authorization
if recipes.include? 'models'
prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
case prefs[:authentication]
when 'devise'
if prefer :orm, 'mongoid'
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"]] unless prefs.has_key? :devise_modules
else
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], ["Devise with Confirmable module","confirmable"],
["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
end
when 'omniauth'
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
end
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization
end
## Form Builder
prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder
## MVC
if (recipes.include? 'models') && (recipes.include? 'controllers') && (recipes.include? 'views') && (recipes.include? 'routes')
if prefer :authorization, 'cancan'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Admin Dashboard", "admin_app"]] unless prefs.has_key? :starter_app
elsif prefer :authentication, 'devise'
if prefer :orm, 'mongoid'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app
else
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
end
elsif prefer :authentication, 'omniauth'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
else
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app
end
end
# save diagnostics before anything can fail
create_file "README", "RECIPES\n#{recipes.sort.inspect}\n"
append_file "README", "PREFERENCES\n#{prefs.inspect}"
# >--------------------------------[ readme ]---------------------------------<
@current_recipe = "readme"
@before_configs["readme"].call if @before_configs["readme"]
say_recipe 'readme'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb
after_everything do
say_wizard "recipe running after everything"
# remove default READMEs
%w{
README
README.rdoc
doc/README_FOR_APP
}.each { |file| remove_file file }
# add placeholder READMEs and humans.txt file
copy_from_repo 'public/humans.txt'
copy_from_repo 'README'
copy_from_repo 'README.textile'
gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
# Diagnostics
gsub_file "README.textile", /recipes that are known/, "recipes that are NOT known" if diagnostics[:recipes] == 'fail'
gsub_file "README.textile", /preferences that are known/, "preferences that are NOT known" if diagnostics[:prefs] == 'fail'
gsub_file "README.textile", /RECIPES/, recipes.sort.inspect
gsub_file "README.textile", /PREFERENCES/, prefs.inspect
gsub_file "README", /RECIPES/, recipes.sort.inspect
gsub_file "README", /PREFERENCES/, prefs.inspect
# Ruby on Rails
gsub_file "README.textile", /\* Ruby/, "* Ruby version #{RUBY_VERSION}"
gsub_file "README.textile", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}"
# Database
gsub_file "README.textile", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql'
gsub_file "README.textile", /SQLite/, "MySQL" if prefer :database, 'mysql'
gsub_file "README.textile", /SQLite/, "MongoDB" if prefer :database, 'mongodb'
gsub_file "README.textile", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid'
# Template Engine
gsub_file "README.textile", /ERB/, "Haml" if prefer :templates, 'haml'
gsub_file "README.textile", /ERB/, "Slim" if prefer :templates, 'slim'
# Testing Framework
gsub_file "README.textile", /Test::Unit/, "RSpec" if prefer :unit_test, 'rspec'
gsub_file "README.textile", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber'
gsub_file "README.textile", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl'
gsub_file "README.textile", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist'
# Front-end Framework
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Sass)" if prefer :bootstrap, 'sass'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Less)" if prefer :bootstrap, 'less'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Zurb Foundation" if prefer :frontend, 'foundation'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Skeleton" if prefer :frontend, 'skeleton'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Normalized CSS" if prefer :frontend, 'normalize'
# Form Builder
gsub_file "README.textile", /Form Builder: None/, "Form Builder: SimpleForm" if prefer :form_builder, 'simple_form'
# Email
unless prefer :email, 'none'
gsub_file "README.textile", /Gmail/, "SMTP" if prefer :email, 'smtp'
gsub_file "README.textile", /Gmail/, "SendGrid" if prefer :email, 'sendgrid'
gsub_file "README.textile", /Gmail/, "Mandrill" if prefer :email, 'mandrill'
else
gsub_file "README.textile", /h2. Email/, ""
gsub_file "README.textile", /The application is configured to send email using a Gmail account./, ""
end
# Authentication and Authorization
gsub_file "README.textile", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise'
gsub_file "README.textile", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth'
gsub_file "README.textile", /Authorization: None/, "Authorization: CanCan" if prefer :authorization, 'cancan'
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: add README files"' if prefer :git, true
end # after_everything
# >---------------------------------[ gems ]----------------------------------<
@current_recipe = "gems"
@before_configs["gems"].call if @before_configs["gems"]
say_recipe 'gems'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb
### GEMFILE ###
## Ruby on Rails
insert_into_file 'Gemfile', "ruby '1.9.3'\n", :before => "gem 'rails', '3.2.6'" if prefer :deploy, 'heroku'
## Web Server
if (prefs[:dev_webserver] == prefs[:prod_webserver])
gem 'thin', '>= 1.5.0' if prefer :dev_webserver, 'thin'
gem 'unicorn', '>= 4.3.1' if prefer :dev_webserver, 'unicorn'
gem 'puma', '>= 1.6.3' if prefer :dev_webserver, 'puma'
else
gem 'thin', '>= 1.5.0', :group => [:development, :test] if prefer :dev_webserver, 'thin'
gem 'unicorn', '>= 4.3.1', :group => [:development, :test] if prefer :dev_webserver, 'unicorn'
gem 'puma', '>= 1.6.3', :group => [:development, :test] if prefer :dev_webserver, 'puma'
gem 'thin', '>= 1.5.0', :group => :production if prefer :prod_webserver, 'thin'
gem 'unicorn', '>= 4.3.1', :group => :production if prefer :prod_webserver, 'unicorn'
gem 'puma', '>= 1.6.3', :group => :production if prefer :prod_webserver, 'puma'
end
## Database Adapter
gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
gem 'mongoid', '>= 3.0.9' if prefer :orm, 'mongoid'
gem 'pg', '>= 0.14.1' if prefer :database, 'postgresql'
gem 'mysql2', '>= 0.3.11' if prefer :database, 'mysql'
## Template Engine
if prefer :templates, 'haml'
gem 'haml', '>= 3.1.7'
gem 'haml-rails', '>= 0.3.5', :group => :development
# hpricot and ruby_parser are needed for conversion of HTML to Haml
gem 'hpricot', '>= 0.8.6', :group => :development
gem 'ruby_parser', '>= 2.3.1', :group => :development
end
if prefer :templates, 'slim'
gem 'slim', '>= 1.3.3'
gem 'haml2slim', '>= 0.4.6', :group => :development
# Haml is needed for conversion of HTML to Slim
gem 'haml', '>= 3.1.6', :group => :development
gem 'haml-rails', '>= 0.3.5', :group => :development
gem 'hpricot', '>= 0.8.6', :group => :development
gem 'ruby_parser', '>= 2.3.1', :group => :development
end
## Testing Framework
if prefer :unit_test, 'rspec'
gem 'rspec-rails', '>= 2.11.4', :group => [:development, :test]
gem 'capybara', '>= 1.1.2', :group => :test if prefer :integration, 'rspec-capybara'
if prefer :orm, 'mongoid'
# use the database_cleaner gem to reset the test database
gem 'database_cleaner', '>= 0.9.1', :group => :test
# include RSpec matchers from the mongoid-rspec gem
gem 'mongoid-rspec', '>= 1.4.6', :group => :test
end
gem 'email_spec', '>= 1.2.1', :group => :test
end
if prefer :unit_test, 'minitest'
gem 'minitest-spec-rails', '>= 3.0.7', :group => :test
gem 'minitest-wscolor', '>= 0.0.3', :group => :test
gem 'capybara', '>= 1.1.2', :group => :test if prefer :integration, 'minitest-capybara'
end
if prefer :integration, 'cucumber'
gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
gem 'database_cleaner', '>= 0.9.1', :group => :test unless prefer :orm, 'mongoid'
gem 'launchy', '>= 2.1.2', :group => :test
gem 'capybara', '>= 1.1.2', :group => :test
end
gem 'turnip', '>= 1.0.0', :group => :test if prefer :integration, 'turnip'
gem 'factory_girl_rails', '>= 4.1.0', :group => [:development, :test] if prefer :fixtures, 'factory_girl'
gem 'fabrication', '>= 2.3.0', :group => [:development, :test] if prefer :fixtures, 'fabrication'
gem 'machinist', '>= 2.0', :group => :test if prefer :fixtures, 'machinist'
## Front-end Framework
gem 'bootstrap-sass', '>= 2.1.0.1' if prefer :bootstrap, 'sass'
gem 'compass-rails', '>= 1.0.3', :group => :assets if prefer :frontend, 'foundation'
gem 'zurb-foundation', '>= 3.2.0', :group => :assets if prefer :frontend, 'foundation'
if prefer :bootstrap, 'less'
gem 'twitter-bootstrap-rails', '>= 2.1.4', :group => :assets
# install gem 'therubyracer' to use Less
gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby
end
## Email
gem 'sendgrid', '>= 1.0.1' if prefer :email, 'sendgrid'
gem 'hominid', '>= 3.0.5' if prefer :email, 'mandrill'
## Authentication (Devise)
gem 'devise', '>= 2.1.2' if prefer :authentication, 'devise'
gem 'devise_invitable', '>= 1.1.1' if prefer :devise_modules, 'invitable'
## Authentication (OmniAuth)
gem 'omniauth', '>= 1.1.1' if prefer :authentication, 'omniauth'
gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter'
gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook'
gem 'omniauth-github' if prefer :omniauth_provider, 'github'
gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin'
gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google_oauth2'
gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
## Authorization
if prefer :authorization, 'cancan'
gem 'cancan', '>= 1.6.8'
gem 'rolify', '>= 3.2.0'
end
## Form Builder
gem 'simple_form', '>= 2.0.4' if prefer :form_builder, 'simple_form'
## Membership App
if prefer :railsapps, 'rails-stripe-membership-saas'
gem 'stripe', '>= 1.7.4'
gem 'stripe_event', '>= 0.4.0'
end
## Signup App
if prefer :railsapps, 'rails-prelaunch-signup'
gem 'google_visualr', '>= 2.1.2'
gem 'jquery-datatables-rails', '>= 1.11.1'
end
## Gems from a defaults file or added interactively
gems.each do |g|
gem g
end
## Git
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: Gemfile"' if prefer :git, true
### CREATE DATABASE ###
after_bundler do
copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql'
copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql'
generate 'mongoid:config' if prefer :orm, 'mongoid'
remove_file 'config/database.yml' if prefer :orm, 'mongoid'
if prefer :database, 'postgresql'
begin
pg_username = ask_wizard("Username for PostgreSQL? (leave blank to use the app name)")
if pg_username.blank?
say_wizard "Creating a user named '#{app_name}' for PostgreSQL"
run "createuser #{app_name}" if prefer :database, 'postgresql'
gsub_file "config/database.yml", /username: .*/, "username: #{app_name}"
else
gsub_file "config/database.yml", /username: .*/, "username: #{pg_username}"
pg_password = ask_wizard("Password for PostgreSQL user #{pg_username}?")
gsub_file "config/database.yml", /password:/, "password: #{pg_password}"
say_wizard "set config/database.yml for username/password #{pg_username}/#{pg_password}"
end
rescue StandardError => e
raise "unable to create a user for PostgreSQL, reason: #{e}"
end
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
end
if prefer :database, 'mysql'
mysql_username = ask_wizard("Username for MySQL? (leave blank to use the app name)")
if mysql_username.blank?
gsub_file "config/database.yml", /username: .*/, "username: #{app_name}"
else
gsub_file "config/database.yml", /username: .*/, "username: #{mysql_username}"
mysql_password = ask_wizard("Password for MySQL user #{mysql_username}?")
gsub_file "config/database.yml", /password:/, "password: #{mysql_password}"
say_wizard "set config/database.yml for username/password #{mysql_username}/#{mysql_password}"
end
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
end
unless prefer :database, 'sqlite'
affirm = yes_wizard? "Drop any existing databases named #{app_name}?"
if affirm
run 'bundle exec rake db:drop'
else
raise "aborted at user's request"
end
end
run 'bundle exec rake db:create:all' unless prefer :orm, 'mongoid'
run 'bundle exec rake db:create' if prefer :orm, 'mongoid'
## Git
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: create database"' if prefer :git, true
end # after_bundler
### GENERATORS ###
after_bundler do
## Front-end Framework
generate 'foundation:install' if prefer :frontend, 'foundation'
## Form Builder
if prefer :form_builder, 'simple_form'
if prefer :frontend, 'bootstrap'
say_wizard "recipe installing simple_form for use with Twitter Bootstrap"
generate 'simple_form:install --bootstrap'
else
say_wizard "recipe installing simple_form"
generate 'simple_form:install'
end
end
## Git
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: generators"' if prefer :git, true
end # after_bundler
# >--------------------------------[ testing ]--------------------------------<
@current_recipe = "testing"
@before_configs["testing"].call if @before_configs["testing"]
say_recipe 'testing'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/testing.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### TEST/UNIT ###
if prefer :unit_test, 'test_unit'
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
config.generators do |g|
#{"g.test_framework :test_unit, fixture_replacement: :fabrication" if prefer :fixtures, 'fabrication'}
#{"g.fixture_replacement :fabrication, dir: 'test/fabricators'" if prefer :fixtures, 'fabrication'}
end
RUBY
end
end
### RSPEC ###
if prefer :unit_test, 'rspec'
say_wizard "recipe installing RSpec"
generate 'rspec:install'
copy_from_repo 'spec/spec_helper.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
generate 'email_spec:steps'
inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
RUBY
end
run 'rm -rf test/' # Removing test folder (not needed for RSpec)
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
# don't generate RSpec tests for views and helpers
config.generators do |g|
#{"g.test_framework :rspec" if prefer :fixtures, 'none'}
#{"g.test_framework :rspec, fixture: true" unless prefer :fixtures, 'none'}
#{"g.fixture_replacement :factory_girl" if prefer :fixtures, 'factory_girl'}
#{"g.fixture_replacement :machinist" if prefer :fixtures, 'machinist'}
#{"g.fixture_replacement :fabrication" if prefer :fixtures, 'fabrication'}
g.view_specs false
g.helper_specs false
end
RUBY
end
## RSPEC AND MONGOID
if prefer :orm, 'mongoid'
# remove ActiveRecord artifacts
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
# remove either possible occurrence of "require rails/test_unit/railtie"
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
# configure RSpec to use matchers from the mongoid-rspec gem
create_file 'spec/support/mongoid.rb' do
<<-RUBY
RSpec.configure do |config|
config.include Mongoid::Matchers
end
RUBY
end
end
## RSPEC AND DEVISE
if prefer :authentication, 'devise'
# add Devise test helpers
create_file 'spec/support/devise.rb' do
<<-RUBY
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
RUBY
end
end
end
### CUCUMBER ###
if prefer :integration, 'cucumber'
say_wizard "recipe installing Cucumber"
generate "cucumber:install --capybara#{' --rspec' if prefer :unit_test, 'rspec'}#{' -D' if prefer :orm, 'mongoid'}"
# make it easy to run Cucumber for single features without adding "--require features" to the command line
gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
create_file 'features/support/email_spec.rb' do <<-RUBY
require 'email_spec/cucumber'
RUBY
end
## CUCUMBER AND MONGOID
if prefer :orm, 'mongoid'
gsub_file 'features/support/env.rb', /transaction/, "truncation"
inject_into_file 'features/support/env.rb', :after => 'begin' do
"\n DatabaseCleaner.orm = 'mongoid'"
end
end
generate 'fabrication:cucumber_steps' if prefer :fixtures, 'fabrication'
end
## TURNIP
if prefer :integration, 'turnip'
append_file '.rspec', '-r turnip/rspec'
inject_into_file 'spec/spec_helper.rb', "require 'turnip/capybara'\n", :after => "require 'rspec/rails'\n"
create_file 'spec/acceptance/steps/.gitkeep'
end
## FIXTURE REPLACEMENTS
if prefer :fixtures, 'machinist'
say_wizard "generating blueprints file for 'machinist'"
generate 'machinist:install'
end
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: testing framework"' if prefer :git, true
end # after_bundler
after_everything do
say_wizard "recipe running after everything"
### RSPEC ###
if prefer :unit_test, 'rspec'
if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
say_wizard "copying RSpec files from the rails3-devise-rspec-cucumber examples"
repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
remove_file 'spec/views/home/index.html.erb_spec.rb'
remove_file 'spec/views/home/index.html.haml_spec.rb'
remove_file 'spec/views/users/show.html.erb_spec.rb'
remove_file 'spec/views/users/show.html.haml_spec.rb'
remove_file 'spec/helpers/home_helper_spec.rb'
remove_file 'spec/helpers/users_helper_spec.rb'
end
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples"
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
remove_file 'spec/views/home/index.html.erb_spec.rb'
remove_file 'spec/views/home/index.html.haml_spec.rb'
remove_file 'spec/views/users/show.html.erb_spec.rb'
remove_file 'spec/views/users/show.html.haml_spec.rb'
remove_file 'spec/helpers/home_helper_spec.rb'
remove_file 'spec/helpers/users_helper_spec.rb'
end
## RSPEC AND OMNIAUTH
if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app')
say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
end
## SUBDOMAINS
if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app')
say_wizard "copying RSpec files from the rails3-subdomains examples"
repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
end
## GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: rspec files"' if prefer :git, true
end
### CUCUMBER ###
if prefer :integration, 'cucumber'
## CUCUMBER AND DEVISE (USERS APP)
if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
say_wizard "copying Cucumber scenarios from the rails3-devise-rspec-cucumber examples"
repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'features/users/sign_in.feature', :repo => repo
copy_from_repo 'features/users/sign_out.feature', :repo => repo
copy_from_repo 'features/users/sign_up.feature', :repo => repo
copy_from_repo 'features/users/user_edit.feature', :repo => repo
copy_from_repo 'features/users/user_show.feature', :repo => repo
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
copy_from_repo 'features/support/paths.rb', :repo => repo
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do
<<-RUBY
Scenario: User has not confirmed account
Given I exist as an unconfirmed user
And I am not logged in
When I sign in with valid credentials
Then I see an unconfirmed account message
And I should be signed out
RUBY
end
end
end
## CUCUMBER AND DEVISE (ADMIN APP)
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
say_wizard "copying Cucumber scenarios from the rails3-bootstrap-devise-cancan examples"
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'features/users/sign_in.feature', :repo => repo
copy_from_repo 'features/users/sign_out.feature', :repo => repo
copy_from_repo 'features/users/sign_up.feature', :repo => repo
copy_from_repo 'features/users/user_edit.feature', :repo => repo
copy_from_repo 'features/users/user_show.feature', :repo => repo
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
copy_from_repo 'features/support/paths.rb', :repo => repo
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
gsub_file 'features/step_definitions/user_steps.rb', /Welcome! You have signed up successfully./, "A message with a confirmation link has been sent to your email address."
inject_into_file 'features/users/sign_in.feature', :before => ' Scenario: User signs in successfully' do
<<-RUBY
Scenario: User has not confirmed account
Given I exist as an unconfirmed user
And I am not logged in
When I sign in with valid credentials
Then I see an unconfirmed account message
And I should be signed out
RUBY
end
end
end
## CUCUMBER AND DEVISE (SUBDOMAINS APP)
if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app')
say_wizard "copying RSpec files from the rails3-subdomains examples"
repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
copy_from_repo 'features/users/sign_in.feature', :repo => repo
copy_from_repo 'features/users/sign_out.feature', :repo => repo
copy_from_repo 'features/users/sign_up.feature', :repo => repo
copy_from_repo 'features/users/user_edit.feature', :repo => repo
copy_from_repo 'features/users/user_show.feature', :repo => repo
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
copy_from_repo 'features/support/paths.rb', :repo => repo
end
## GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: cucumber files"' if prefer :git, true
end
### FABRICATION ###
if prefer :fixtures, 'fabrication'
say_wizard "replacing FactoryGirl fixtures with Fabrication"
remove_file 'spec/factories/users.rb'
remove_file 'spec/fabricators/user_fabricator.rb'
create_file 'spec/fabricators/user_fabricator.rb' do
<<-RUBY
Fabricator(:user) do
name 'Test User'
email 'example@example.com'
password 'please'
password_confirmation 'please'
# required if the Devise Confirmable module is used
# confirmed_at Time.now
end
RUBY
end
if prefer :integration, 'cucumber'
gsub_file 'features/step_definitions/user_steps.rb', /@user = FactoryGirl.create\(:user, email: @visitor\[:email\]\)/, '@user = Fabricate(:user, email: @visitor[:email])'
end
gsub_file 'spec/controllers/users_controller_spec.rb', /@user = FactoryGirl.create\(:user\)/, '@user = Fabricate(:user)'
end
end # after_everything
# >---------------------------------[ email ]---------------------------------<
@current_recipe = "email"
@before_configs["email"].call if @before_configs["email"]
say_recipe 'email'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/email.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
unless prefer :email, 'none'
### DEVELOPMENT
gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
<<-RUBY
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
RUBY
end
### TEST
inject_into_file 'config/environments/test.rb', :before => "\nend" do
<<-RUBY
\n
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'example.com' }
RUBY
end
### PRODUCTION
gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do
<<-RUBY
config.active_support.deprecation = :notify
config.action_mailer.default_url_options = { :host => 'example.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
RUBY
end
end
### GMAIL ACCOUNT
if prefer :email, 'gmail'
gmail_configuration_text = <<-TEXT
\n
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "example.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
TEXT
inject_into_file 'config/environments/development.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
inject_into_file 'config/environments/production.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
end
### SENDGRID ACCOUNT
if prefer :email, 'sendgrid'
sendgrid_configuration_text = <<-TEXT
\n
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 25,
domain: "example.com",
authentication: "plain",
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"]
}
TEXT
inject_into_file 'config/environments/development.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
inject_into_file 'config/environments/production.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
end
### MANDRILL ACCOUNT
if prefer :email, 'mandrill'
mandrill_configuration_text = <<-TEXT
\n
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 25,
:user_name => ENV["MANDRILL_USERNAME"],
:password => ENV["MANDRILL_API_KEY"]
}
TEXT
inject_into_file 'config/environments/development.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
inject_into_file 'config/environments/production.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
end
### GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: set email accounts"' if prefer :git, true
end # after_bundler
# >--------------------------------[ models ]---------------------------------<
@current_recipe = "models"
@before_configs["models"].call if @before_configs["models"]
say_recipe 'models'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/models.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### DEVISE ###
if prefer :authentication, 'devise'
# prevent logging of password_confirmation
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
generate 'devise:install'
generate 'devise_invitable:install' if prefer :devise_modules, 'invitable'
generate 'devise user' # create the User model
if prefer :orm, 'mongoid'
## DEVISE AND MONGOID
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-devise/master/'
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
gsub_file 'app/models/user.rb', /# field :confirmation_token/, "field :confirmation_token"
gsub_file 'app/models/user.rb', /# field :confirmed_at/, "field :confirmed_at"
gsub_file 'app/models/user.rb', /# field :confirmation_sent_at/, "field :confirmation_sent_at"
gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email"
end
if (prefer :devise_modules, 'invitable')
gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
<<-RUBY
#invitable
field :invitation_token, :type => String
field :invitation_sent_at, :type => Time
field :invitation_accepted_at, :type => Time
field :invitation_limit, :type => Integer
field :invited_by_id, :type => String
field :invited_by_type, :type => String
end
RUBY
end
end
else
## DEVISE AND ACTIVE RECORD
generate 'migration AddNameToUsers name:string'
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
end
end
## DEVISE AND CUCUMBER
if prefer :integration, 'cucumber'
# Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
# (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
end
end
### OMNIAUTH ###
if prefer :authentication, 'omniauth'
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
copy_from_repo 'config/initializers/omniauth.rb', :repo => repo
gsub_file 'config/initializers/omniauth.rb', /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
generate 'model User name:string email:string provider:string uid:string' unless prefer :orm, 'mongoid'
run 'bundle exec rake db:migrate' unless prefer :orm, 'mongoid'
copy_from_repo 'app/models/user.rb', :repo => repo # copy the User model (Mongoid version)
unless prefer :orm, 'mongoid'
## OMNIAUTH AND ACTIVE RECORD
gsub_file 'app/models/user.rb', /class User/, 'class User < ActiveRecord::Base'
gsub_file 'app/models/user.rb', /^\s*include Mongoid::Document\n/, ''
gsub_file 'app/models/user.rb', /^\s*field.*\n/, ''
gsub_file 'app/models/user.rb', /^\s*# run 'rake db:mongoid:create_indexes' to create indexes\n/, ''
gsub_file 'app/models/user.rb', /^\s*index\(\{ email: 1 \}, \{ unique: true, background: true \}\)\n/, ''
end
end
### SUBDOMAINS ###
copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
### AUTHORIZATION ###
if prefer :authorization, 'cancan'
generate 'cancan:ability'
if prefer :starter_app, 'admin_app'
# Limit access to the users#index page
copy_from_repo 'app/models/ability.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
# allow an admin to update roles
insert_into_file 'app/models/user.rb', " attr_accessible :role_ids, :as => :admin\n", :before => " attr_accessible"
end
unless prefer :orm, 'mongoid'
generate 'rolify:role Role User'
else
generate 'rolify:role Role User mongoid'
# correct the generation of rolify 3.1 with mongoid
# the call to `rolify` should be *after* the inclusion of mongoid
# (see https://github.com/EppO/rolify/issues/61)
# This isn't needed for rolify>=3.2.0.beta4, but should cause no harm
gsub_file 'app/models/user.rb',
/^\s*(rolify.*?)$\s*(include Mongoid::Document.*?)$/,
" \\2\n extend Rolify\n \\1\n"
end
end
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: models"' if prefer :git, true
end # after_bundler
# >------------------------------[ controllers ]------------------------------<
@current_recipe = "controllers"
@before_configs["controllers"].call if @before_configs["controllers"]
say_recipe 'controllers'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/controllers.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### APPLICATION_CONTROLLER ###
if prefer :authentication, 'omniauth'
copy_from_repo 'app/controllers/application_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
end
if prefer :authorization, 'cancan'
inject_into_file 'app/controllers/application_controller.rb', :before => "\nend" do <<-RUBY
\n
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_path, :alert => exception.message
end
RUBY
end
end
### HOME_CONTROLLER ###
if ['home_app','users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
generate(:controller, "home index")
end
if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
gsub_file 'app/controllers/home_controller.rb', /def index/, "def index\n @users = User.all"
end
### USERS_CONTROLLER ###
case prefs[:starter_app]
when 'users_app'
if prefer :authentication, 'devise'
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
elsif prefer :authentication, 'omniauth'
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
end
when 'admin_app'
if prefer :authentication, 'devise'
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
elsif prefer :authentication, 'omniauth'
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
end
when 'subdomains_app'
copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
end
### SESSIONS_CONTROLLER ###
if prefer :authentication, 'omniauth'
filename = 'app/controllers/sessions_controller.rb'
copy_from_repo filename, :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
if prefer :authorization, 'cancan'
inject_into_file filename, " user.add_role :admin if User.count == 1 # make the first user an admin\n", :after => "session[:user_id] = user.id\n"
end
end
### PROFILES_CONTROLLER ###
copy_from_repo 'app/controllers/profiles_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: controllers"' if prefer :git, true
end # after_bundler
# >---------------------------------[ views ]---------------------------------<
@current_recipe = "views"
@before_configs["views"].call if @before_configs["views"]
say_recipe 'views'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/views.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### DEVISE ###
if prefer :authentication, 'devise'
copy_from_repo 'app/views/devise/shared/_links.html.erb'
unless prefer :form_builder, 'simple_form'
copy_from_repo 'app/views/devise/registrations/edit.html.erb'
copy_from_repo 'app/views/devise/registrations/new.html.erb'
else
copy_from_repo 'app/views/devise/registrations/edit-simple_form.html.erb', :prefs => 'simple_form'
copy_from_repo 'app/views/devise/registrations/new-simple_form.html.erb', :prefs => 'simple_form'
copy_from_repo 'app/views/devise/sessions/new-simple_form.html.erb', :prefs => 'simple_form'
end
end
### HOME ###
copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'users_app'
copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'admin_app'
copy_from_repo 'app/views/home/index-subdomains_app.html.erb', :prefs => 'subdomains_app'
### USERS ###
if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
## INDEX
if prefer :starter_app, 'admin_app'
copy_from_repo 'app/views/users/index.html.erb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
unless prefer :railsapps, 'rails-prelaunch-signup'
copy_from_repo 'app/views/users/_user.html.erb', :repo => 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
end
else
copy_from_repo 'app/views/users/index.html.erb'
end
## SHOW
copy_from_repo 'app/views/users/show.html.erb'
copy_from_repo 'app/views/users/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
## EDIT
copy_from_repo 'app/views/users/edit-omniauth.html.erb', :prefs => 'omniauth'
end
### PROFILES ###
copy_from_repo 'app/views/profiles/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: views"' if prefer :git, true
end # after_bundler
# >--------------------------------[ routes ]---------------------------------<
@current_recipe = "routes"
@before_configs["routes"].call if @before_configs["routes"]
say_recipe 'routes'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/routes.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### HOME ###
if prefer :starter_app, 'home_app'
remove_file 'public/index.html'
gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
end
### USER_ACCOUNTS ###
if ['users_app','admin_app'].include? prefs[:starter_app]
## DEVISE
copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' if prefer :authentication, 'devise'
## OMNIAUTH
copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' if prefer :authentication, 'omniauth'
end
### SUBDOMAINS ###
copy_from_repo 'lib/subdomain.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains_app'
### CORRECT APPLICATION NAME ###
gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: routes"' if prefer :git, true
end # after_bundler
# >-------------------------------[ frontend ]--------------------------------<
@current_recipe = "frontend"
@before_configs["frontend"].call if @before_configs["frontend"]
say_recipe 'frontend'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/frontend.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### LAYOUTS ###
copy_from_repo 'app/views/layouts/application.html.erb'
copy_from_repo 'app/views/layouts/application-bootstrap.html.erb', :prefs => 'bootstrap'
copy_from_repo 'app/views/layouts/_messages.html.erb'
copy_from_repo 'app/views/layouts/_messages-bootstrap.html.erb', :prefs => 'bootstrap'
copy_from_repo 'app/views/layouts/_navigation.html.erb'
if prefer :authorization, 'cancan'
case prefs[:authentication]
when 'devise'
copy_from_repo 'app/views/layouts/_navigation-cancan.html.erb', :prefs => 'cancan'
when 'omniauth'
copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/app/views/layouts/_navigation-cancan-omniauth.html.erb', 'app/views/layouts/_navigation.html.erb'
end
else
copy_from_repo 'app/views/layouts/_navigation-devise.html.erb', :prefs => 'devise'
copy_from_repo 'app/views/layouts/_navigation-omniauth.html.erb', :prefs => 'omniauth'
end
copy_from_repo 'app/views/layouts/_navigation-subdomains_app.html.erb', :prefs => 'subdomains_app'
## APPLICATION NAME
application_layout_file = Dir['app/views/layouts/application.html.*'].first
navigation_partial_file = Dir['app/views/layouts/_navigation.html.*'].first
gsub_file application_layout_file, /App_Name/, "#{app_name.humanize.titleize}"
gsub_file navigation_partial_file, /App_Name/, "#{app_name.humanize.titleize}"
### CSS ###
copy_from_repo 'app/assets/stylesheets/application.css.scss'
copy_from_repo 'app/assets/stylesheets/application-bootstrap.css.scss', :prefs => 'bootstrap'
if prefer :bootstrap, 'less'
generate 'bootstrap:install'
insert_into_file 'app/assets/stylesheets/bootstrap_and_overrides.css.less', "body { padding-top: 60px; }\n", :after => "@import \"twitter/bootstrap/bootstrap\";\n"
elsif prefer :bootstrap, 'sass'
insert_into_file 'app/assets/javascripts/application.js', "//= require bootstrap\n", :after => "jquery_ujs\n"
create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY
@import "bootstrap";
body { padding-top: 60px; }
@import "bootstrap-responsive";
RUBY
elsif prefer :frontend, 'foundation'
insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation_and_overrides\n", :after => "require_self\n"
elsif prefer :frontend, 'skeleton'
copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css'
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css'
copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css'
elsif prefer :frontend, 'normalize'
copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
end
remove_file 'app/assets/stylesheets/application.css'
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: front-end framework"' if prefer :git, true
end # after_bundler
# >---------------------------------[ init ]----------------------------------<
@current_recipe = "init"
@before_configs["init"].call if @before_configs["init"]
say_recipe 'init'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/init.rb
after_everything do
say_wizard "recipe running after everything"
### PREPARE SEED ###
if prefer :authentication, 'devise'
if (prefer :authorization, 'cancan') && !(prefer :railsapps, 'rails-prelaunch-signup')
append_file 'db/seeds.rb' do <<-FILE
puts 'CREATING ROLES'
Role.create([
{ :name => 'admin' },
{ :name => 'user' },
{ :name => 'VIP' }
], :without_protection => true)
FILE
end
end
if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
## DEVISE-CONFIRMABLE
append_file 'db/seeds.rb' do <<-FILE
puts 'SETTING UP DEFAULT USER LOGIN'
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please'
user.confirm!
puts 'New user created: ' << user.name
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please'
user2.confirm!
puts 'New user created: ' << user2.name
FILE
end
else
## DEVISE-DEFAULT
append_file 'db/seeds.rb' do <<-FILE
puts 'SETTING UP DEFAULT USER LOGIN'
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user.name
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please'
puts 'New user created: ' << user2.name
FILE
end
end
if prefer :starter_app, 'subdomains_app'
gsub_file 'db/seeds.rb', /First User/, 'user1'
gsub_file 'db/seeds.rb', /Second User/, 'user2'
end
if prefer :authorization, 'cancan'
append_file 'db/seeds.rb' do <<-FILE
user.add_role :admin
user2.add_role :VIP
FILE
end
end
if prefer :railsapps, 'rails-prelaunch-signup'
gsub_file 'db/seeds.rb', /user2.add_role :VIP/, ''
end
## DEVISE-INVITABLE
if prefer :devise_modules, 'invitable'
run 'bundle exec rake db:migrate'
generate 'devise_invitable user'
end
end
### APPLY SEED ###
unless prefer :orm, 'mongoid'
## ACTIVE_RECORD
say_wizard "applying migrations and seeding the database"
run 'bundle exec rake db:migrate'
run 'bundle exec rake db:test:prepare'
else
## MONGOID
say_wizard "dropping database, creating indexes and seeding the database"
run 'bundle exec rake db:drop'
run 'bundle exec rake db:mongoid:create_indexes'
end
run 'bundle exec rake db:seed'
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: set up database"' if prefer :git, true
end # after_everything
# >-------------------------------[ prelaunch ]-------------------------------<
@current_recipe = "prelaunch"
@before_configs["prelaunch"].call if @before_configs["prelaunch"]
say_recipe 'prelaunch'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/prelaunch.rb
if prefer :railsapps, 'rails-prelaunch-signup'
after_everything do
say_wizard "recipe running after 'bundle install'"
repo = 'https://raw.github.com/RailsApps/rails-prelaunch-signup/master/'
# >-------------------------------[ Clean up starter app ]--------------------------------<
%w{
public/index.html
app/assets/images/rails.png
}.each { |file| remove_file file }
# remove commented lines and multiple blank lines from Gemfile
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
gsub_file 'Gemfile', /#.*\n/, "\n"
gsub_file 'Gemfile', /\n^\s*\n/, "\n"
# remove commented lines and multiple blank lines from config/routes.rb
gsub_file 'config/routes.rb', / #.*\n/, "\n"
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
# GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: clean up starter app"' if prefer :git, true
# >-------------------------------[ Create a git branch ]--------------------------------<
if prefer :git, true
if prefer :prelaunch_branch, 'master'
unless prefer :main_branch, 'none'
say_wizard "renaming git branch 'master' to '#{prefs[:main_branch]}' for starter app"
git :branch => "-m master #{prefs[:main_branch]}"
git :checkout => "-b master"
else
say_wizard "creating prelaunch app on git branch 'master'"
end
else
say_wizard "creating new git branch '#{prefs[:prelaunch_branch]}' for prelaunch app"
git :checkout => "-b #{prefs[:prelaunch_branch]}"
end
end
# >-------------------------------[ Cucumber ]--------------------------------<
say_wizard "copying Cucumber scenarios from the rails-prelaunch-signup examples"
copy_from_repo 'features/admin/send_invitations.feature', :repo => repo
copy_from_repo 'features/admin/view_progress.feature', :repo => repo
copy_from_repo 'features/visitors/request_invitation.feature', :repo => repo
copy_from_repo 'features/users/sign_in.feature', :repo => repo
copy_from_repo 'features/users/sign_up.feature', :repo => repo
copy_from_repo 'features/users/user_show.feature', :repo => repo
copy_from_repo 'features/step_definitions/admin_steps.rb', :repo => repo
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
copy_from_repo 'features/step_definitions/visitor_steps.rb', :repo => repo
copy_from_repo 'config/locales/devise.en.yml', :repo => repo
# >-------------------------------[ Migrations ]--------------------------------<
generate 'migration AddOptinToUsers opt_in:boolean'
run 'bundle exec rake db:drop'
run 'bundle exec rake db:migrate'
run 'bundle exec rake db:test:prepare'
run 'bundle exec rake db:seed'
# >-------------------------------[ Models ]--------------------------------<
copy_from_repo 'app/models/user.rb', :repo => repo
# >-------------------------------[ Controllers ]--------------------------------<
copy_from_repo 'app/controllers/confirmations_controller.rb', :repo => repo
copy_from_repo 'app/controllers/home_controller.rb', :repo => repo
copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo
copy_from_repo 'app/controllers/users_controller.rb', :repo => repo
# >-------------------------------[ Mailers ]--------------------------------<
generate 'mailer UserMailer'
copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo
copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo
# >-------------------------------[ Views ]--------------------------------<
copy_from_repo 'app/views/devise/confirmations/show.html.erb', :repo => repo
copy_from_repo 'app/views/devise/mailer/confirmation_instructions.html.erb', :repo => repo
copy_from_repo 'app/views/devise/registrations/_thankyou.html.erb', :repo => repo
copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo
copy_from_repo 'app/views/devise/shared/_links.html.erb', :repo => repo
copy_from_repo 'app/views/home/index.html.erb', :repo => repo
copy_from_repo 'app/views/user_mailer/welcome_email.html.erb', :repo => repo
copy_from_repo 'app/views/user_mailer/welcome_email.text.erb', :repo => repo
copy_from_repo 'app/views/users/index.html.erb', :repo => repo
copy_from_repo 'public/thankyou.html', :repo => repo
# >-------------------------------[ Routes ]--------------------------------<
copy_from_repo 'config/routes.rb', :repo => repo
### CORRECT APPLICATION NAME ###
gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
# >-------------------------------[ Assets ]--------------------------------<
copy_from_repo 'app/assets/javascripts/application.js', :repo => repo
copy_from_repo 'app/assets/javascripts/users.js.coffee', :repo => repo
copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: prelaunch app"' if prefer :git, true
end # after_bundler
end # rails-prelaunch-signup
# >-------------------------------[ prelaunch ]-------------------------------<
@current_recipe = "saas"
@before_configs["saas"].call if @before_configs["saas"]
say_recipe 'prelaunch'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/saas.rb
if prefer :railsapps, 'rails-stripe-membership-saas'
after_everything do
say_wizard "recipe running after 'bundle install'"
repo = 'https://raw.github.com/RailsApps/rails-stripe-membership-saas/master/'
# >-------------------------------[ Clean up starter app ]--------------------------------<
%w{
public/index.html
app/assets/images/rails.png
}.each { |file| remove_file file }
# remove commented lines and multiple blank lines from Gemfile
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
gsub_file 'Gemfile', /#.*\n/, "\n"
gsub_file 'Gemfile', /\n^\s*\n/, "\n"
# remove commented lines and multiple blank lines from config/routes.rb
gsub_file 'config/routes.rb', / #.*\n/, "\n"
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
# GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: clean up starter app"' if prefer :git, true
# >-------------------------------[ Cucumber ]--------------------------------<
say_wizard "copying Cucumber scenarios from the rails-stripe-membership-saas examples"
remove_file 'features/users/user_show.feature'
copy_from_repo 'features/users/sign_in.feature', :repo => repo
copy_from_repo 'features/users/sign_up.feature', :repo => repo
copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
copy_from_repo 'config/locales/devise.en.yml', :repo => repo
# >-------------------------------[ Models ]--------------------------------<
copy_from_repo 'app/models/ability.rb', :repo => repo
copy_from_repo 'app/models/user.rb', :repo => repo
# >-------------------------------[ Init ]--------------------------------<
copy_from_repo 'db/seeds.rb', :repo => repo
copy_from_repo 'config/initializers/stripe.rb', :repo => repo
# >-------------------------------[ Migrations ]--------------------------------<
generate 'migration AddStripeToUsers customer_id:string last_4_digits:string'
run 'bundle exec rake db:drop'
run 'bundle exec rake db:migrate'
run 'bundle exec rake db:test:prepare'
run 'bundle exec rake db:seed'
# >-------------------------------[ Controllers ]--------------------------------<
copy_from_repo 'app/controllers/home_controller.rb', :repo => repo
generate 'controller content silver gold platinum --skip-stylesheets --skip-javascripts'
copy_from_repo 'app/controllers/content_controller.rb', :repo => repo
copy_from_repo 'app/controllers/registrations_controller.rb', :repo => repo
copy_from_repo 'app/controllers/application_controller.rb', :repo => repo
copy_from_repo 'app/controllers/users_controller.rb', :repo => repo
# >-------------------------------[ Mailers ]--------------------------------<
generate 'mailer UserMailer'
copy_from_repo 'app/mailers/user_mailer.rb', :repo => repo
# >-------------------------------[ Views ]--------------------------------<
copy_from_repo 'app/views/home/index.html.erb', :repo => repo
copy_from_repo 'app/views/layouts/_navigation.html.erb', :repo => repo
copy_from_repo 'app/views/devise/registrations/new.html.erb', :repo => repo
copy_from_repo 'app/views/devise/registrations/edit.html.erb', :repo => repo
copy_from_repo 'app/views/user_mailer/expire_email.html.erb', :repo => repo
copy_from_repo 'app/views/user_mailer/expire_email.text.erb', :repo => repo
# >-------------------------------[ Routes ]--------------------------------<
copy_from_repo 'config/routes.rb', :repo => repo
### CORRECT APPLICATION NAME ###
gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
# >-------------------------------[ Assets ]--------------------------------<
copy_from_repo 'app/assets/javascripts/application.js', :repo => repo
copy_from_repo 'app/assets/javascripts/jquery.readyselector.js', :repo => repo
copy_from_repo 'app/assets/javascripts/jquery.externalscript.js', :repo => repo
copy_from_repo 'app/assets/javascripts/registrations.js.erb', :repo => repo
copy_from_repo 'app/assets/stylesheets/application.css.scss', :repo => repo
copy_from_repo 'app/assets/stylesheets/pricing.css.scss', :repo => repo
# >-------------------------------[ RSpec ]--------------------------------<
say_wizard "copying RSpec tests from the rails-stripe-membership-saas examples"
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/content_controller_spec.rb', :repo => repo
copy_from_repo 'spec/mailers/user_mailer_spec.rb', :repo => repo
### GIT ###
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: membership app"' if prefer :git, true
end # after_bundler
end # rails-stripe-membership-saas
# >--------------------------------[ extras ]---------------------------------<
@current_recipe = "extras"
@before_configs["extras"].call if @before_configs["extras"]
say_recipe 'extras'
config = {}
config['quiet_assets'] = yes_wizard?("Reduce assets logger noise during development?") if true && true unless config.key?('quiet_assets') || prefs.has_key?(:quiet_assets)
config['ban_spiders'] = yes_wizard?("Set a robots.txt file to ban spiders?") if true && true unless config.key?('ban_spiders') || prefs.has_key?(:ban_spiders)
config['rvmrc'] = yes_wizard?("Create a project-specific rvm gemset and .rvmrc?") if true && true unless config.key?('rvmrc') || prefs.has_key?(:rvmrc)
config['github'] = yes_wizard?("Create a GitHub repository?") if true && true unless config.key?('github') || prefs.has_key?(:github)
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb
## QUIET ASSETS
if config['quiet_assets']
prefs[:quiet_assets] = true
end
if prefs[:quiet_assets]
say_wizard "recipe setting quiet_assets for reduced asset pipeline logging"
gem 'quiet_assets', '>= 1.0.1', :group => :development
end
## BAN SPIDERS
if config['ban_spiders']
prefs[:ban_spiders] = true
end
if prefs[:ban_spiders]
say_wizard "recipe banning spiders by modifying 'public/robots.txt'"
after_bundler do
gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
end
end
## JSRUNTIME
case RbConfig::CONFIG['host_os']
when /linux/i
prefs[:jsruntime] = yes_wizard? "Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?" unless prefs.has_key? :jsruntime
if prefs[:jsruntime]
# was it already added for bootstrap-less?
unless prefer :bootstrap, 'less'
say_wizard "recipe adding 'therubyracer' JavaScript runtime gem"
gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby
end
end
end
## RVMRC
if config['rvmrc']
prefs[:rvmrc] = true
end
if prefs[:rvmrc]
say_wizard "recipe creating project-specific rvm gemset and .rvmrc"
# using the rvm Ruby API, see:
# http://blog.thefrontiergroup.com.au/2010/12/a-brief-introduction-to-the-rvm-ruby-api/
# https://rvm.io/integration/passenger
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems')
ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global"
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
raise "RVM gem is currently unavailable."
end
end
say_wizard "creating RVM gemset '#{app_name}'"
RVM.gemset_create app_name
run "rvm rvmrc trust"
say_wizard "switching to gemset '#{app_name}'"
# RVM.gemset_use! requires rvm version 1.11.3.5 or newer
rvm_spec =
if Gem::Specification.respond_to?(:find_by_name)
Gem::Specification.find_by_name("rvm")
else
Gem.source_index.find_name("rvm").last
end
unless rvm_spec.version > Gem::Version.create('1.11.3.4')
say_wizard "rvm gem version: #{rvm_spec.version}"
raise "Please update rvm gem to 1.11.3.5 or newer"
end
begin
RVM.gemset_use! app_name
rescue => e
say_wizard "rvm failure: unable to use gemset #{app_name}, reason: #{e}"
raise
end
run "rvm gemset list"
copy_from_repo '.rvmrc'
gsub_file '.rvmrc', /App_Name/, "#{app_name}"
end
## AFTER_EVERYTHING
after_everything do
say_wizard "recipe removing unnecessary files and whitespace"
%w{
public/index.html
app/assets/images/rails.png
}.each { |file| remove_file file }
# remove commented lines and multiple blank lines from Gemfile
# thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
gsub_file 'Gemfile', /#.*\n/, "\n"
gsub_file 'Gemfile', /\n^\s*\n/, "\n"
# remove commented lines and multiple blank lines from config/routes.rb
gsub_file 'config/routes.rb', / #.*\n/, "\n"
gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
# GIT
git :add => '-A' if prefer :git, true
git :commit => '-qm "rails_apps_composer: extras"' if prefer :git, true
end
## GITHUB
if config['github']
prefs[:github] = true
end
if prefs[:github]
gem 'hub', '>= 1.10.2', :require => nil, :group => [:development]
after_everything do
say_wizard "recipe creating GitHub repository"
git_uri = `git config remote.origin.url`.strip
unless git_uri.size == 0
say_wizard "Repository already exists:"
say_wizard "#{git_uri}"
else
run "hub create #{app_name}"
unless prefer :railsapps, 'rails-prelaunch-signup'
run "hub push -u origin master"
else
run "hub push -u origin #{prefs[:prelaunch_branch]}"
run "hub push -u origin #{prefs[:main_branch]}" unless prefer :main_branch, 'none'
end
end
end
end
# >---------------------------------[ Diagnostics ]----------------------------------<
# remove prefs which are diagnostically irrelevant
redacted_prefs = prefs.clone
redacted_prefs.delete(:git)
redacted_prefs.delete(:dev_webserver)
redacted_prefs.delete(:prod_webserver)
redacted_prefs.delete(:templates)
redacted_prefs.delete(:quiet_assets)
redacted_prefs.delete(:ban_spiders)
redacted_prefs.delete(:jsruntime)
redacted_prefs.delete(:rvmrc)
redacted_prefs.delete(:github)
redacted_prefs.delete(:prelaunch_branch)
redacted_prefs.delete(:main_branch)
if diagnostics_prefs.include? redacted_prefs
diagnostics[:prefs] = 'success'
else
diagnostics[:prefs] = 'fail'
end
@current_recipe = nil
# >-----------------------------[ Run 'Bundle Install' ]-------------------------------<
say_wizard "Installing gems. This will take a while."
if prefs.has_key? :bundle_path
run "bundle install --without production --path #{prefs[:bundle_path]}"
else
run 'bundle install --without production'
end
# >-----------------------------[ Run 'After Bundler' Callbacks ]-------------------------------<
say_wizard "Running 'after bundler' callbacks."
require 'bundler/setup'
if prefer :templates, 'haml'
say_wizard "importing html2haml conversion tool"
require 'haml/html'
end
if prefer :templates, 'slim'
say_wizard "importing html2haml and haml2slim conversion tools"
require 'haml/html'
require 'haml2slim'
end
@after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
# >-----------------------------[ Run 'After Everything' Callbacks ]-------------------------------<
@current_recipe = nil
say_wizard "Running 'after everything' callbacks."
@after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
@current_recipe = nil
if diagnostics[:recipes] == 'success'
say_wizard("WOOT! The recipes you've selected are known to work together.")
say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.")
else
say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m")
say_wizard("Help us out by reporting whether this combination works or fails.")
say_wizard("Please open an issue for rails_apps_composer on GitHub.")
say_wizard("Your new application will contain diagnostics in its README file.")
end
if diagnostics[:prefs] == 'success'
say_wizard("WOOT! The preferences you've selected are known to work together.")
say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.")
else
say_wizard("\033[1m\033[36m" + "WARNING! The preferences you've selected might not work together." + "\033[0m")
say_wizard("Help us out by reporting whether this combination works or fails.")
say_wizard("Please open an issue for rails_apps_composer on GitHub.")
say_wizard("Your new application will contain diagnostics in its README file.")
end
say_wizard "Finished running the rails_apps_composer app template."
say_wizard "Your new Rails app is ready. Time to run 'bundle install'."
================================================
FILE: rails3-bootstrap-devise-cancan-template.rb
================================================
# >---------------------------------------------------------------------------<
#
# _____ _ _
# | __ \ (_) | /\
# | |__) |__ _ _| |___ / \ _ __ _ __ ___
# | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __|
# | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \
# |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/
# | | | |
# |_| |_|
#
# Template generated by rails_apps_composer. For more information, see:
# https://github.com/RailsApps/rails_apps_composer/
# Thank you to Michael Bleigh for leading the way with the RailsWizard gem.
#
# >---------------------------------------------------------------------------<
# >----------------------------[ Initial Setup ]------------------------------<
run 'bundle update'
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
end
RUBY
@recipes = ["core", "git", "railsapps", "setup", "readme", "gems", "testing", "email", "models", "controllers", "views", "routes", "frontend", "init", "prelaunch", "extras"]
@prefs = {:railsapps=>"rails3-bootstrap-devise-cancan", :dev_webserver=>"webrick", :prod_webserver=>"same", :ban_spiders=>true, :jsruntime=>false, :rvmrc=>true}
@gems = []
@diagnostics_recipes = [["example"], ["setup"], ["railsapps"], ["gems", "setup"], ["gems", "readme", "setup"], ["extras", "gems", "readme", "setup"], ["example", "git"], ["git", "setup"], ["git", "railsapps"], ["gems", "git", "setup"], ["gems", "git", "readme", "setup"], ["extras", "gems", "git", "readme", "setup"], ["controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"]]
@diagnostics_prefs = [{:railsapps=>"rails-prelaunch-signup", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"mandrill", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"simple_form"}, {:railsapps=>"rails3-bootstrap-devise-cancan", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :starter_app=>"admin_app", :form_builder=>"none"}, {:railsapps=>"rails3-devise-rspec-cucumber", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-devise", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-mongoid-omniauth", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"none", :starter_app=>"users_app", :form_builder=>"none"}, {:railsapps=>"rails3-subdomains", :database=>"mongodb", :orm=>"mongoid", :templates=>"haml", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :starter_app=>"subdomains_app", :form_builder=>"none"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"capybara", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"none", :authentication=>"omniauth", :omniauth_provider=>"twitter", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"invitable", :authorization=>"cancan", :form_builder=>"simple_form", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"rspec", :integration=>"cucumber", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}, {:railsapps=>"none", :database=>"sqlite", :unit_test=>"test_unit", :integration=>"none", :fixtures=>"none", :frontend=>"bootstrap", :bootstrap=>"less", :email=>"sendgrid", :authentication=>"devise", :devise_modules=>"confirmable", :authorization=>"cancan", :form_builder=>"none", :starter_app=>"admin_app"}]
diagnostics = {}
def recipes; @recipes end
def recipe?(name); @recipes.include?(name) end
def prefs; @prefs end
def prefer(key, value); @prefs[key].eql? value end
def gems; @gems end
def diagnostics_recipes; @diagnostics_recipes end
def diagnostics_prefs; @diagnostics_prefs end
def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
def ask_wizard(question)
ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[1m\033[36m" + " #{question}\033[0m"
end
def yes_wizard?(question)
answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
case answer.downcase
when "yes", "y"
true
when "no", "n"
false
else
yes_wizard?(question)
end
end
def no_wizard?(question); !yes_wizard?(question) end
def multiple_choice(question, choices)
say_custom('question', question)
values = {}
choices.each_with_index do |choice,i|
values[(i + 1).to_s] = choice[1]
say_custom (i + 1).to_s + ')', choice[0]
end
answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
values[answer]
end
@current_recipe = nil
@configs = {}
@after_blocks = []
def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
@after_everything_blocks = []
def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
@before_configs = {}
def before_config(&block); @before_configs[@current_recipe] = block; end
def copy_from(source, destination)
begin
remove_file destination
get source, destination
rescue OpenURI::HTTPError
say_wizard "Unable to obtain #{source}"
end
end
def copy_from_repo(filename, opts = {})
repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/'
repo = opts[:repo] unless opts[:repo].nil?
if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs])
return
end
source_filename = filename
destination_filename = filename
unless opts[:prefs].nil?
if filename.include? opts[:prefs]
destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '')
end
end
if (prefer :templates, 'haml') && (filename.include? 'views')
remove_file destination_filename
destination_filename = destination_filename.gsub(/.erb/, '.haml')
end
if (prefer :templates, 'slim') && (filename.include? 'views')
remove_file destination_filename
destination_filename = destination_filename.gsub(/.erb/, '.slim')
end
begin
remove_file destination_filename
if (prefer :templates, 'haml') && (filename.include? 'views')
create_file destination_filename, html_to_haml(repo + source_filename)
elsif (prefer :templates, 'slim') && (filename.include? 'views')
create_file destination_filename, html_to_slim(repo + source_filename)
else
get repo + source_filename, destination_filename
end
rescue OpenURI::HTTPError
say_wizard "Unable to obtain #{source_filename} from the repo #{repo}"
end
end
def html_to_haml(source)
html = open(source) {|input| input.binmode.read }
Haml::HTML.new(html, :erb => true, :xhtml => true).render
end
def html_to_slim(source)
html = open(source) {|input| input.binmode.read }
haml = Haml::HTML.new(html, :erb => true, :xhtml => true).render
Haml2Slim.convert!(haml)
end
if diagnostics_recipes.sort.include? recipes.sort
diagnostics[:recipes] = 'success'
say_wizard("WOOT! The recipes you've selected are known to work together.")
else
diagnostics[:recipes] = 'fail'
say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m")
say_wizard("Help us out by reporting whether this combination works or fails.")
say_wizard("Please open an issue for rails_apps_composer on GitHub.")
say_wizard("Your new application will contain diagnostics in its README file.")
say_wizard("Continuing...")
end
# this application template only supports Rails version 3.1 and newer
case Rails::VERSION::MAJOR.to_s
when "3"
case Rails::VERSION::MINOR.to_s
when "0"
say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
end
else
say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
end
say_wizard "Using rails_apps_composer recipes to generate an application."
# >---------------------------[ Autoload Modules/Classes ]-----------------------------<
inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY'
config.autoload_paths += %W(#{config.root}/lib)
RUBY
end
# >---------------------------------[ Recipes ]----------------------------------<
# >---------------------------------[ core ]----------------------------------<
@current_recipe = "core"
@before_configs["core"].call if @before_configs["core"]
say_recipe 'core'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/core.rb
## Git
say_wizard "selected all core recipes"
# >----------------------------------[ git ]----------------------------------<
@current_recipe = "git"
@before_configs["git"].call if @before_configs["git"]
say_recipe 'git'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb
## Git
say_wizard "initialize git"
prefs[:git] = true unless prefs.has_key? :git
if prefer :git, true
copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
git :init
git :add => '.'
git :commit => "-aqm 'rails_apps_composer: initial commit'"
end
# >-------------------------------[ railsapps ]-------------------------------<
@current_recipe = "railsapps"
@before_configs["railsapps"].call if @before_configs["railsapps"]
say_recipe 'railsapps'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/railsapps.rb
prefs[:railsapps] = multiple_choice "Install an example application?",
[["I want to build my own application", "none"],
["rails3-bootstrap-devise-cancan", "rails3-bootstrap-devise-cancan"],
["rails3-devise-rspec-cucumber", "rails3-devise-rspec-cucumber"],
["rails3-mongoid-devise", "rails3-mongoid-devise"],
["rails3-mongoid-omniauth", "rails3-mongoid-omniauth"],
["rails3-subdomains", "rails3-subdomains"]] unless prefs.has_key? :railsapps
case prefs[:railsapps]
when 'rails-prelaunch-signup'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'bootstrap'
prefs[:bootstrap] = 'sass'
prefs[:email] = 'mandrill'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'confirmable'
prefs[:authorization] = 'cancan'
prefs[:starter_app] = 'admin_app'
prefs[:form_builder] = 'simple_form'
if prefer :git, true
prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?", [["wip (work-in-progress)", "wip"], ["master", "master"], ["prelaunch", "prelaunch"], ["staging", "staging"]]
if prefs[:prelaunch_branch] == 'master'
prefs[:main_branch] = multiple_choice "Git branch for the main app?", [["None", "none"], ["wip (work-in-progress)", "wip"], ["edge", "edge"]]
else
prefs[:main_branch] = 'master'
end
end
when 'rails3-bootstrap-devise-cancan'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'bootstrap'
prefs[:bootstrap] = 'sass'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'cancan'
prefs[:starter_app] = 'admin_app'
prefs[:form_builder] = 'none'
when 'rails3-devise-rspec-cucumber'
prefs[:git] = true
prefs[:database] = 'sqlite'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
when 'rails3-mongoid-devise'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
when 'rails3-mongoid-omniauth'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'none'
prefs[:authentication] = 'omniauth'
prefs[:omniauth_provider] = 'twitter'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'users_app'
prefs[:form_builder] = 'none'
when 'rails3-subdomains'
prefs[:git] = true
prefs[:database] = 'mongodb'
prefs[:orm] = 'mongoid'
prefs[:unit_test] = 'rspec'
prefs[:integration] = 'cucumber'
prefs[:fixtures] = 'factory_girl'
prefs[:frontend] = 'none'
prefs[:email] = 'gmail'
prefs[:authentication] = 'devise'
prefs[:devise_modules] = 'default'
prefs[:authorization] = 'none'
prefs[:starter_app] = 'subdomains_app'
prefs[:form_builder] = 'none'
end
# >---------------------------------[ setup ]---------------------------------<
@current_recipe = "setup"
@before_configs["setup"].call if @before_configs["setup"]
say_recipe 'setup'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb
## Ruby on Rails
HOST_OS = RbConfig::CONFIG['host_os']
say_wizard "Your operating system is #{HOST_OS}."
say_wizard "You are using Ruby version #{RUBY_VERSION}."
say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
## Is sqlite3 in the Gemfile?
gemfile = File.read(destination_root() + '/Gemfile')
sqlite_detected = gemfile.include? 'sqlite3'
## Web Server
prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"],
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :dev_webserver
webserver = multiple_choice "Web server for production?", [["Same as development", "same"],
["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :prod_webserver
if webserver == 'same'
case prefs[:dev_webserver]
when 'thin'
prefs[:prod_webserver] = 'thin'
when 'unicorn'
prefs[:prod_webserver] = 'unicorn'
when 'puma'
prefs[:prod_webserver] = 'puma'
end
else
prefs[:prod_webserver] = webserver
end
## Database Adapter
prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"],
["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database
case prefs[:database]
when 'mongodb'
unless sqlite_detected
prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm
else
say_wizard "WARNING! SQLite gem detected in the Gemfile"
say_wizard "If you wish to use MongoDB you must skip Active Record."
say_wizard "If using rails_apps_composer, choose 'skip Active Record'."
say_wizard "If using Rails Composer or an application template, use the '-O' flag as in 'rails new foo -O'."
prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]]
if prefer :fail, 'abort'
raise StandardError.new "SQLite detected in the Gemfile. Use '-O' or '--skip-activerecord' as in 'rails new foo -O' if you don't want ActiveRecord and SQLite"
end
end
end
## Template Engine
prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates
## Testing Framework
if recipes.include? 'testing'
prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"]] unless prefs.has_key? :unit_test
prefs[:integration] = multiple_choice "Integration testing?", [["None", "none"], ["RSpec with Capybara", "capybara"],
["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"]] unless prefs.has_key? :integration
prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"]] unless prefs.has_key? :fixtures
end
## Front-end Framework
if recipes.include? 'frontend'
prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], ["Twitter Bootstrap", "bootstrap"],
["Zurb Foundation", "foundation"], ["Skeleton", "skeleton"], ["Just normalize CSS for consistent styling", "normalize"]] unless prefs.has_key? :frontend
if prefer :frontend, 'bootstrap'
case HOST_OS
when /mswin|windows/i
prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap
else
prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Less)", "less"],
["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap
end
end
end
## Email
if recipes.include? 'email'
prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"],
["SendGrid","sendgrid"], ["Mandrill","mandrill"]] unless prefs.has_key? :email
else
prefs[:email] = 'none'
end
## Authentication and Authorization
if recipes.include? 'models'
prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
case prefs[:authentication]
when 'devise'
if prefer :orm, 'mongoid'
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"]] unless prefs.has_key? :devise_modules
else
prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], ["Devise with Confirmable module","confirmable"],
["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
end
when 'omniauth'
prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"],
["LinkedIn", "linkedin"], ["Google-Oauth-2", "google-oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
end
prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization
end
## Form Builder
prefs[:form_builder] = multiple_choice "Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]] unless prefs.has_key? :form_builder
## MVC
if (recipes.include? 'models') && (recipes.include? 'controllers') && (recipes.include? 'views') && (recipes.include? 'routes')
if prefer :authorization, 'cancan'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Admin Dashboard", "admin_app"]] unless prefs.has_key? :starter_app
elsif prefer :authentication, 'devise'
if prefer :orm, 'mongoid'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app
else
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
end
elsif prefer :authentication, 'omniauth'
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"],
["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
else
prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app
end
end
# save diagnostics before anything can fail
create_file "README", "RECIPES\n#{recipes.sort.inspect}\n"
append_file "README", "PREFERENCES\n#{prefs.inspect}"
# >--------------------------------[ readme ]---------------------------------<
@current_recipe = "readme"
@before_configs["readme"].call if @before_configs["readme"]
say_recipe 'readme'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb
after_everything do
say_wizard "recipe running after everything"
# remove default READMEs
%w{
README
README.rdoc
doc/README_FOR_APP
}.each { |file| remove_file file }
# add placeholder READMEs and humans.txt file
copy_from_repo 'public/humans.txt'
copy_from_repo 'README'
copy_from_repo 'README.textile'
gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
gsub_file "README.textile", /App_Name/, "#{app_name.humanize.titleize}"
# Diagnostics
gsub_file "README.textile", /recipes that are known/, "recipes that are NOT known" if diagnostics[:recipes] == 'fail'
gsub_file "README.textile", /preferences that are known/, "preferences that are NOT known" if diagnostics[:prefs] == 'fail'
gsub_file "README.textile", /RECIPES/, recipes.sort.inspect
gsub_file "README.textile", /PREFERENCES/, prefs.inspect
gsub_file "README", /RECIPES/, recipes.sort.inspect
gsub_file "README", /PREFERENCES/, prefs.inspect
# Ruby on Rails
gsub_file "README.textile", /\* Ruby/, "* Ruby version #{RUBY_VERSION}"
gsub_file "README.textile", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}"
# Database
gsub_file "README.textile", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql'
gsub_file "README.textile", /SQLite/, "MySQL" if prefer :database, 'mysql'
gsub_file "README.textile", /SQLite/, "MongoDB" if prefer :database, 'mongodb'
gsub_file "README.textile", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid'
# Template Engine
gsub_file "README.textile", /ERB/, "Haml" if prefer :templates, 'haml'
gsub_file "README.textile", /ERB/, "Slim" if prefer :templates, 'slim'
# Testing Framework
gsub_file "README.textile", /Test::Unit/, "RSpec" if prefer :unit_test, 'rspec'
gsub_file "README.textile", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber'
gsub_file "README.textile", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl'
gsub_file "README.textile", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist'
# Front-end Framework
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Sass)" if prefer :bootstrap, 'sass'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Less)" if prefer :bootstrap, 'less'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Zurb Foundation" if prefer :frontend, 'foundation'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Skeleton" if prefer :frontend, 'skeleton'
gsub_file "README.textile", /Front-end Framework: None/, "Front-end Framework: Normalized CSS" if prefer :frontend, 'normalize'
# Form Builder
gsub_file "README.textile", /Form Builder: None/, "Form Builder: SimpleForm" if prefer :form_builder, 'simple_form'
# Email
unless prefer :email, 'none'
gsub_file "README.textile", /Gmail/, "SMTP" if prefer :email, 'smtp'
gsub_file "README.textile", /Gmail/, "SendGrid" if prefer :email, 'sendgrid'
gsub_file "README.textile", /Gmail/, "Mandrill" if prefer :email, 'mandrill'
else
gsub_file "README.textile", /h2. Email/, ""
gsub_file "README.textile", /The application is configured to send email using a Gmail account./, ""
end
# Authentication and Authorization
gsub_file "README.textile", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise'
gsub_file "README.textile", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth'
gsub_file "README.textile", /Authorization: None/, "Authorization: CanCan" if prefer :authorization, 'cancan'
git :add => '.' if prefer :git, true
git :commit => "-aqm 'rails_apps_composer: add README files'" if prefer :git, true
end # after_everything
# >---------------------------------[ gems ]----------------------------------<
@current_recipe = "gems"
@before_configs["gems"].call if @before_configs["gems"]
say_recipe 'gems'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb
### GEMFILE ###
## Ruby on Rails
insert_into_file 'Gemfile', "ruby '1.9.3'\n", :before => "gem 'rails', '3.2.6'" if prefer :deploy, 'heroku'
## Web Server
if (prefs[:dev_webserver] == prefs[:prod_webserver])
gem 'thin', '>= 1.4.1' if prefer :dev_webserver, 'thin'
gem 'unicorn', '>= 4.3.1' if prefer :dev_webserver, 'unicorn'
gem 'puma', '>= 1.6.3' if prefer :dev_webserver, 'puma'
else
gem 'thin', '>= 1.4.1', :group => [:development, :test] if prefer :dev_webserver, 'thin'
gem 'unicorn', '>= 4.3.1', :group => [:development, :test] if prefer :dev_webserver, 'unicorn'
gem 'puma', '>= 1.6.3', :group => [:development, :test] if prefer :dev_webserver, 'puma'
gem 'thin', '>= 1.4.1', :group => :production if prefer :prod_webserver, 'thin'
gem 'unicorn', '>= 4.3.1', :group => :production if prefer :prod_webserver, 'unicorn'
gem 'puma', '>= 1.6.3', :group => :production if prefer :prod_webserver, 'puma'
end
## Database Adapter
gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
gem 'mongoid', '>= 3.0.5' if prefer :orm, 'mongoid'
gem 'pg', '>= 0.14.1' if prefer :database, 'postgresql'
gem 'mysql2', '>= 0.3.11' if prefer :database, 'mysql'
## Template Engine
if prefer :templates, 'haml'
gem 'haml', '>= 3.1.7'
gem 'haml-rails', '>= 0.3.5', :group => :development
# hpricot and ruby_parser are needed for conversion of HTML to Haml
gem 'hpricot', '>= 0.8.6', :group => :development
gem 'ruby_parser', '>= 2.3.1', :group => :development
end
if prefer :templates, 'slim'
gem 'slim', '>= 1.3.0'
gem 'haml2slim', '>= 0.4.6', :group => :development
# Haml is needed for conversion of HTML to Slim
gem 'haml', '>= 3.1.6', :group => :development
gem 'haml-rails', '>= 0.3.5', :group => :development
gem 'hpricot', '>= 0.8.6', :group => :development
gem 'ruby_parser', '>= 2.3.1', :group => :development
end
## Testing Framework
if prefer :unit_test, 'rspec'
gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test]
gem 'capybara', '>= 1.1.2', :group => :test
if prefer :orm, 'mongoid'
# use the database_cleaner gem to reset the test database
gem 'database_cleaner', '>= 0.8.0', :group => :test
# include RSpec matchers from the mongoid-rspec gem
gem 'mongoid-rspec', '>= 1.4.6', :group => :test
end
gem 'email_spec', '>= 1.2.1', :group => :test unless prefer :email, 'none'
end
if prefer :integration, 'cucumber'
gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
gem 'database_cleaner', '>= 0.8.0', :group => :test unless prefer :orm, 'mongoid'
gem 'launchy', '>= 2.1.2', :group => :test
end
gem 'turnip', '>= 1.0.0', :group => :test if prefer :integration, 'turnip'
gem 'factory_girl_rails', '>= 4.0.0', :group => [:development, :test] if prefer :fixtures, 'factory_girl'
gem 'machinist', '>= 2.0', :group => :test if prefer :fixtures, 'machinist'
## Front-end Framework
gem 'bootstrap-sass', '>= 2.1.0.0' if prefer :bootstrap, 'sass'
gem 'compass-rails', '>= 1.0.3', :group => :assets if prefer :frontend, 'foundation'
gem 'zurb-foundation', '>= 3.0.9', :group => :assets if prefer :frontend, 'foundation'
if prefer :bootstrap, 'less'
gem 'twitter-bootstrap-rails', '>= 2.1.3', :group => :assets
# install gem 'therubyracer' to use Less
gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby
end
## Email
gem 'sendgrid', '>= 1.0.1' if prefer :email, 'sendgrid'
gem 'hominid', '>= 3.0.5' if prefer :email, 'mandrill'
## Authentication (Devise)
gem 'devise', '>= 2.1.2' if prefer :authentication, 'devise'
gem 'devise_invitable', '>= 1.0.3' if prefer :devise_modules, 'invitable'
## Authentication (OmniAuth)
gem 'omniauth', '>= 1.1.1' if prefer :authentication, 'omniauth'
gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter'
gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook'
gem 'omniauth-github' if prefer :omniauth_provider, 'github'
gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin'
gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google-oauth2'
gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
## Authorization
if prefer :authorization, 'cancan'
gem 'cancan', '>= 1.6.8'
gem 'rolify', '>= 3.2.0'
end
## Form Builder
gem 'simple_form', '>= 2.0.2' if prefer :form_builder, 'simple_form'
## Signup App
if prefer :railsapps, 'rails-prelaunch-signup'
gem 'google_visualr', '>= 2.1.2'
gem 'jquery-datatables-rails', '>= 1.11.0'
end
## Gems from a defaults file or added interactively
gems.each do |g|
gem g
end
## Git
git :add => '.' if prefer :git, true
git :commit => "-aqm 'rails_apps_composer: Gemfile'" if prefer :git, true
### CREATE DATABASE ###
after_bundler do
copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql'
copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql'
generate 'mongoid:config' if prefer :orm, 'mongoid'
remove_file 'config/database.yml' if prefer :orm, 'mongoid'
if prefer :database, 'postgresql'
begin
say_wizard "Creating a user named '#{app_name}' for PostgreSQL"
run "createuser #{app_name}" if prefer :database, 'postgresql'
gsub_file "config/database.yml", /username: .*/, "username: #{app_name}"
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
rescue StandardError
raise "unable to create a user for PostgreSQL"
end
end
if prefer :database, 'mysql'
gsub_file "config/database.yml", /database: myapp_development/, "database: #{app_name}_development"
gsub_file "config/database.yml", /database: myapp_test/, "database: #{app_name}_test"
gsub_file "config/database.yml", /database: myapp_production/, "database: #{app_name}_production"
end
unless prefer :database, 'sqlite'
affirm = multiple_choice "Drop any existing databases named #{app_name}?",
[["Yes (continue)",true], ["No (abort)",false]]
if affirm
run 'bundle exec rake db:drop'
else
raise "aborted at user's request"
end
end
run 'bundle exec rake db:create:all' unless prefer :orm, 'mongoid'
run 'bundle exec rake db:create' if prefer :orm, 'mongoid'
## Git
git :add => '.' if prefer :git, true
git :commit => "-aqm 'rails_apps_composer: create database'" if prefer :git, true
end # after_bundler
### GENERATORS ###
after_bundler do
## Front-end Framework
generate 'foundation:install' if prefer :frontend, 'foundation'
## Form Builder
if prefer :form_builder, 'simple_form'
if prefer :frontend, 'bootstrap'
say_wizard "recipe installing simple_form for use with Twitter Bootstrap"
generate 'simple_form:install --bootstrap'
else
say_wizard "recipe installing simple_form"
generate 'simple_form:install'
end
end
## Git
git :add => '.' if prefer :git, true
git :commit => "-aqm 'rails_apps_composer: generators'" if prefer :git, true
end # after_bundler
# >--------------------------------[ testing ]--------------------------------<
@current_recipe = "testing"
@before_configs["testing"].call if @before_configs["testing"]
say_recipe 'testing'
@configs[@current_recipe] = config
# Application template recipe for the rails_apps_composer. Change the recipe here:
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/testing.rb
after_bundler do
say_wizard "recipe running after 'bundle install'"
### RSPEC ###
if prefer :unit_test, 'rspec'
say_wizard "recipe installing RSpec"
generate 'rspec:install'
copy_from_repo 'spec/spec_helper.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
unless prefer :email, 'none'
generate 'email_spec:steps'
inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
RUBY
end
end
run 'rm -rf test/' # Removing test folder (not needed for RSpec)
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
# don't generate RSpec tests for views and helpers
config.generators do |g|
g.view_specs false
g.helper_specs false
#{"g.fixture_replacement :machinist" if prefer :fixtures, 'machinist'}
end
RUBY
end
## RSPEC AND MONGOID
if prefer :orm, 'mongoid'
# remove ActiveRecord artifacts
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
# remove either possible occurrence of "require rails/test_unit/railtie"
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
# configure RSpec to use matchers from the mongoid-rspec gem
create_file 'spec/support/mongoid.rb' do
<<-RUBY
RSpec.configure do |config|
config.include Mongoid::Matchers
end
RUBY
end
end
## RSPEC AND DEVISE
if prefer :authentication, 'devise'
# add Devise test helpers
create_file 'spec/support/devise.rb' do
<<-RUBY
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
RUBY
end
end
end
### CUCUMBER ###
if prefer :integration, 'cucumber'
say_wizard "recipe installing Cucumber"
generate "cucumber:install --capybara#{' --rspec' if prefer :unit_test, 'rspec'}#{' -D' if prefer :orm, 'mongoid'}"
# make it easy to run Cucumber for single features without adding "--require features" to the command line
gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
unless prefer :email, 'none'
create_file 'features/support/email_spec.rb' do <<-RUBY
require 'email_spec/cucumber'
RUBY
end
end
## CUCUMBER AND MONGOID
if prefer :orm, 'mongoid'
gsub_file 'features/support/env.rb', /transaction/, "truncation"
inject_into_file 'features/support/env.rb', :after => 'begin' do
"\n DatabaseCleaner.orm = 'mongoid'"
end
end
end
## TURNIP
if prefer :integration, 'turnip'
append_file '.rspec', '-r turnip/rspec'
inject_into_file 'spec/spec_helper.rb', "require 'turnip/capybara'\n", :after => "require 'rspec/rails'\n"
create_file 'spec/acceptance/steps/.gitkeep'
end
## FIXTURE REPLACEMENTS
if prefer :fixtures, 'machinist'
say_wizard "generating blueprints file for 'machinist'"
generate 'machinist:install'
end
### GIT ###
git :add => '.' if prefer :git, true
git :commit => "-aqm 'rails_apps_composer: testing framework'" if prefer :git, true
end # after_bundler
after_everything do
say_wizard "recipe running after everything"
### RSPEC ###
if prefer :unit_test, 'rspec'
if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
say_wizard "copying RSpec files from the rails3-devise-rspec-cucumber examples"
repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
remove_file 'spec/views/home/index.html.erb_spec.rb'
remove_file 'spec/views/home/index.html.haml_spec.rb'
remove_file 'spec/views/users/show.html.erb_spec.rb'
remove_file 'spec/views/users/show.html.haml_spec.rb'
remove_file 'spec/helpers/home_helper_spec.rb'
remove_file 'spec/helpers/users_helper_spec.rb'
end
if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples"
repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
remove_file 'spec/views/home/index.html.erb_spec.rb'
remove_file 'spec/views/home/index.html.haml_spec.rb'
remove_file 'spec/views/users/show.html.erb_spec.rb'
remove_file 'spec/views/users/show.html.haml_spec.rb'
remove_file 'spec/helpers/home_helper_spec.rb'
remove_file 'spec/helpers/users_helper_spec.rb'
end
## RSPEC AND OMNIAUTH
if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app')
say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
copy_from_repo 'spec/models/user_spec.rb', :repo => repo
end
## SUBDOMAINS
if (prefer :authentication, 'devise') && (prefer :starter_app, 'subdomains_app')
say_wizard "copying RSpec files from the rails3-subdomains examples"
repo = 'https://raw.github.com/RailsApps/rails3-subdomains/master/'
copy_from_repo 'spec/factories/users.rb', :repo => repo
copy_from_repo 'spec/controllers/home_controller_spec.rb', :
gitextract_6n8lovbq/ ├── .gitignore ├── README ├── README.textile ├── files/ │ ├── devise-views-haml/ │ │ └── app/ │ │ └── views/ │ │ └── devise/ │ │ ├── _links.erb │ │ ├── registrations/ │ │ │ ├── edit.html.haml │ │ │ └── new.html.haml │ │ └── shared/ │ │ └── _links.html.haml │ ├── gitignore.txt │ ├── humans.txt │ ├── navigation/ │ │ ├── devise/ │ │ │ ├── _navigation.html.erb │ │ │ ├── _navigation.html.haml │ │ │ └── authorization/ │ │ │ ├── _navigation.html.erb │ │ │ └── _navigation.html.haml │ │ ├── none/ │ │ │ ├── _navigation.html.erb │ │ │ └── _navigation.html.haml │ │ ├── omniauth/ │ │ │ ├── _navigation.html.erb │ │ │ └── _navigation.html.haml │ │ └── subdomains/ │ │ ├── _navigation.html.erb │ │ └── _navigation.html.haml │ ├── sample_readme.textile │ ├── sample_readme.txt │ ├── simple/ │ │ ├── assets/ │ │ │ └── stylesheets/ │ │ │ └── application.css.scss │ │ └── views/ │ │ └── layouts/ │ │ ├── _messages.html.erb │ │ ├── _messages.html.haml │ │ ├── application.html.erb │ │ └── application.html.haml │ ├── twitter-bootstrap/ │ │ ├── assets/ │ │ │ └── stylesheets/ │ │ │ └── application.css.scss │ │ └── views/ │ │ └── layouts/ │ │ ├── _messages.html.erb │ │ ├── _messages.html.haml │ │ ├── application.html.erb │ │ └── application.html.haml │ └── views/ │ └── layouts/ │ ├── application.html.erb │ └── application.html.haml ├── files-v2/ │ ├── .rvmrc │ ├── README │ ├── README.textile │ ├── app/ │ │ ├── assets/ │ │ │ └── stylesheets/ │ │ │ ├── application-bootstrap.css.scss │ │ │ └── application.css.scss │ │ └── views/ │ │ ├── devise/ │ │ │ ├── registrations/ │ │ │ │ ├── edit.html.erb │ │ │ │ ├── edit.html.haml │ │ │ │ ├── new.html.erb │ │ │ │ └── new.html.haml │ │ │ └── shared/ │ │ │ ├── _links.html.erb │ │ │ └── _links.html.haml │ │ ├── home/ │ │ │ ├── index-subdomains_app.html.erb │ │ │ ├── index-subdomains_app.html.haml │ │ │ ├── index.html.erb │ │ │ └── index.html.haml │ │ ├── layouts/ │ │ │ ├── _messages-bootstrap.html.erb │ │ │ ├── _messages-bootstrap.html.haml │ │ │ ├── _messages.html.erb │ │ │ ├── _messages.html.haml │ │ │ ├── _navigation-cancan.html.erb │ │ │ ├── _navigation-cancan.html.haml │ │ │ ├── _navigation-devise.html.erb │ │ │ ├── _navigation-devise.html.haml │ │ │ ├── _navigation-omniauth.html.erb │ │ │ ├── _navigation-omniauth.html.haml │ │ │ ├── _navigation-subdomains_app.html.erb │ │ │ ├── _navigation-subdomains_app.html.haml │ │ │ ├── _navigation.html.erb │ │ │ ├── _navigation.html.haml │ │ │ ├── application-bootstrap.html.erb │ │ │ ├── application-bootstrap.html.haml │ │ │ ├── application.html.erb │ │ │ └── application.html.haml │ │ ├── profiles/ │ │ │ ├── show-subdomains_app.html.erb │ │ │ └── show-subdomains_app.html.haml │ │ └── users/ │ │ ├── edit-omniauth.html.erb │ │ ├── edit-omniauth.html.haml │ │ ├── index.html.erb │ │ ├── index.html.haml │ │ ├── show-subdomains_app.html.erb │ │ ├── show-subdomains_app.html.haml │ │ ├── show.html.erb │ │ └── show.html.haml │ ├── config/ │ │ ├── database-mysql.yml │ │ └── database-postgresql.yml │ └── public/ │ └── humans.txt ├── rails-prelaunch-signup-template.rb ├── rails3-bootstrap-devise-cancan-template.rb ├── rails3-devise-rspec-cucumber-template.rb ├── rails3-haml-html5-template.rb ├── rails3-mongoid-devise-template.rb ├── rails3-mongoid-omniauth-template.rb └── rails3-subdomains-template.rb
SYMBOL INDEX (138 symbols across 7 files)
FILE: rails-prelaunch-signup-template.rb
function recipes (line 39) | def recipes; @recipes end
function recipe? (line 40) | def recipe?(name); @recipes.include?(name) end
function prefs (line 41) | def prefs; @prefs end
function prefer (line 42) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 43) | def gems; @gems end
function diagnostics_recipes (line 44) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 45) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 47) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 48) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 49) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 51) | def ask_wizard(question)
function yes_wizard? (line 55) | def yes_wizard?(question)
function no_wizard? (line 67) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 69) | def multiple_choice(question, choices)
function after_bundler (line 84) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 86) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 88) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 90) | def copy_from(source, destination)
function copy_from_repo (line 99) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 134) | def html_to_haml(source)
function html_to_slim (line 139) | def html_to_slim(source)
FILE: rails3-bootstrap-devise-cancan-template.rb
function recipes (line 34) | def recipes; @recipes end
function recipe? (line 35) | def recipe?(name); @recipes.include?(name) end
function prefs (line 36) | def prefs; @prefs end
function prefer (line 37) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 38) | def gems; @gems end
function diagnostics_recipes (line 39) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 40) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 42) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 43) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 44) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 46) | def ask_wizard(question)
function yes_wizard? (line 50) | def yes_wizard?(question)
function no_wizard? (line 62) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 64) | def multiple_choice(question, choices)
function after_bundler (line 79) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 81) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 83) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 85) | def copy_from(source, destination)
function copy_from_repo (line 94) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 129) | def html_to_haml(source)
function html_to_slim (line 134) | def html_to_slim(source)
FILE: rails3-devise-rspec-cucumber-template.rb
function recipes (line 34) | def recipes; @recipes end
function recipe? (line 35) | def recipe?(name); @recipes.include?(name) end
function prefs (line 36) | def prefs; @prefs end
function prefer (line 37) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 38) | def gems; @gems end
function diagnostics_recipes (line 39) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 40) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 42) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 43) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 44) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 46) | def ask_wizard(question)
function yes_wizard? (line 50) | def yes_wizard?(question)
function no_wizard? (line 62) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 64) | def multiple_choice(question, choices)
function after_bundler (line 79) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 81) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 83) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 85) | def copy_from(source, destination)
function copy_from_repo (line 94) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 129) | def html_to_haml(source)
function html_to_slim (line 134) | def html_to_slim(source)
FILE: rails3-haml-html5-template.rb
function recipes (line 41) | def recipes; @recipes end
function recipe? (line 42) | def recipe?(name); @recipes.include?(name) end
function say_custom (line 44) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 45) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 46) | def say_wizard(text); say_custom(@current_recipe || 'wizard', text) end
function ask_wizard (line 48) | def ask_wizard(question)
function yes_wizard? (line 52) | def yes_wizard?(question)
function no_wizard? (line 64) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 66) | def multiple_choice(question, choices)
function after_bundler (line 81) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 83) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 85) | def before_config(&block); @before_configs[@current_recipe] = block; end
FILE: rails3-mongoid-devise-template.rb
function recipes (line 34) | def recipes; @recipes end
function recipe? (line 35) | def recipe?(name); @recipes.include?(name) end
function prefs (line 36) | def prefs; @prefs end
function prefer (line 37) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 38) | def gems; @gems end
function diagnostics_recipes (line 39) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 40) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 42) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 43) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 44) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 46) | def ask_wizard(question)
function yes_wizard? (line 50) | def yes_wizard?(question)
function no_wizard? (line 62) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 64) | def multiple_choice(question, choices)
function after_bundler (line 79) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 81) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 83) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 85) | def copy_from(source, destination)
function copy_from_repo (line 94) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 129) | def html_to_haml(source)
function html_to_slim (line 134) | def html_to_slim(source)
FILE: rails3-mongoid-omniauth-template.rb
function recipes (line 34) | def recipes; @recipes end
function recipe? (line 35) | def recipe?(name); @recipes.include?(name) end
function prefs (line 36) | def prefs; @prefs end
function prefer (line 37) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 38) | def gems; @gems end
function diagnostics_recipes (line 39) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 40) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 42) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 43) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 44) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 46) | def ask_wizard(question)
function yes_wizard? (line 50) | def yes_wizard?(question)
function no_wizard? (line 62) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 64) | def multiple_choice(question, choices)
function after_bundler (line 79) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 81) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 83) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 85) | def copy_from(source, destination)
function copy_from_repo (line 94) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 129) | def html_to_haml(source)
function html_to_slim (line 134) | def html_to_slim(source)
FILE: rails3-subdomains-template.rb
function recipes (line 34) | def recipes; @recipes end
function recipe? (line 35) | def recipe?(name); @recipes.include?(name) end
function prefs (line 36) | def prefs; @prefs end
function prefer (line 37) | def prefer(key, value); @prefs[key].eql? value end
function gems (line 38) | def gems; @gems end
function diagnostics_recipes (line 39) | def diagnostics_recipes; @diagnostics_recipes end
function diagnostics_prefs (line 40) | def diagnostics_prefs; @diagnostics_prefs end
function say_custom (line 42) | def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + ...
function say_recipe (line 43) | def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033...
function say_wizard (line 44) | def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
function ask_wizard (line 46) | def ask_wizard(question)
function yes_wizard? (line 50) | def yes_wizard?(question)
function no_wizard? (line 62) | def no_wizard?(question); !yes_wizard?(question) end
function multiple_choice (line 64) | def multiple_choice(question, choices)
function after_bundler (line 79) | def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
function after_everything (line 81) | def after_everything(&block); @after_everything_blocks << [@current_reci...
function before_config (line 83) | def before_config(&block); @before_configs[@current_recipe] = block; end
function copy_from (line 85) | def copy_from(source, destination)
function copy_from_repo (line 94) | def copy_from_repo(filename, opts = {})
function html_to_haml (line 129) | def html_to_haml(source)
function html_to_slim (line 134) | def html_to_slim(source)
Condensed preview — 86 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (604K chars).
[
{
"path": ".gitignore",
"chars": 49,
"preview": ".bundle\ndb/*.sqlite3\nlog/*.log\ntmp/**/*\n.DS_Store"
},
{
"path": "README",
"chars": 344,
"preview": "Rails3-Application-Templates\n========================\n\nYou can use these templates to generate a Rails web application.\n"
},
{
"path": "README.textile",
"chars": 7961,
"preview": "h1. !http://railsapps.github.com/images/rails-36x36.jpg(Rails 3.2 Application Templates)! Rails 3.2 Application Template"
},
{
"path": "files/devise-views-haml/app/views/devise/_links.erb",
"chars": 1100,
"preview": "<%- if controller_name != 'sessions' %>\n <%= link_to \"Sign in\", new_session_path(resource_name) %><br />\n<% end -%>\n\n<%"
},
{
"path": "files/devise-views-haml/app/views/devise/registrations/edit.html.haml",
"chars": 914,
"preview": "%h2\n Edit #{resource_name.to_s.humanize}\n= form_for(resource, :as => resource_name, :url => registration_path(resource_"
},
{
"path": "files/devise-views-haml/app/views/devise/registrations/new.html.haml",
"chars": 495,
"preview": "%h2 Sign up\n= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|\n = devise_error"
},
{
"path": "files/devise-views-haml/app/views/devise/shared/_links.html.haml",
"chars": 958,
"preview": "- if controller_name != 'sessions'\n = link_to \"Sign in\", new_session_path(resource_name)\n %br/\n- if devise_mapping.reg"
},
{
"path": "files/gitignore.txt",
"chars": 1545,
"preview": "#----------------------------------------------------------------------------\n# Ignore these files when commiting to a g"
},
{
"path": "files/humans.txt",
"chars": 366,
"preview": "/* the humans responsible & colophon */\n/* humanstxt.org */\n\n\n/* TEAM */\n <your title>: <your name>\n Site:\n Twitter:\n"
},
{
"path": "files/navigation/devise/_navigation.html.erb",
"chars": 512,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n <%= lin"
},
{
"path": "files/navigation/devise/_navigation.html.haml",
"chars": 390,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n = link_to('Logout', dest"
},
{
"path": "files/navigation/devise/authorization/_navigation.html.erb",
"chars": 633,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n <%= lin"
},
{
"path": "files/navigation/devise/authorization/_navigation.html.haml",
"chars": 478,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n = link_to('Logout', dest"
},
{
"path": "files/navigation/none/_navigation.html.erb",
"chars": 55,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>"
},
{
"path": "files/navigation/none/_navigation.html.haml",
"chars": 50,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'"
},
{
"path": "files/navigation/omniauth/_navigation.html.erb",
"chars": 321,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n Logged "
},
{
"path": "files/navigation/omniauth/_navigation.html.haml",
"chars": 232,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n Logged in as #{current_u"
},
{
"path": "files/navigation/subdomains/_navigation.html.erb",
"chars": 815,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <li>\n <%= link_to 'Main', root_url(:host ="
},
{
"path": "files/navigation/subdomains/_navigation.html.haml",
"chars": 638,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n %li\n = link_to 'Main', root_url(:host => request.domain)"
},
{
"path": "files/sample_readme.textile",
"chars": 1340,
"preview": "h1. App_Name\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nh2. More Information\n\nLorem ipsum dolor sit amet"
},
{
"path": "files/sample_readme.txt",
"chars": 70,
"preview": "App_Name\n========================\n\n\n________________________\n\nLicense\n"
},
{
"path": "files/simple/assets/stylesheets/application.css.scss",
"chars": 899,
"preview": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below"
},
{
"path": "files/simple/views/layouts/_messages.html.erb",
"chars": 117,
"preview": "<% flash.each do |name, msg| %>\n <%= content_tag :div, msg, :id => \"flash_#{name}\" if msg.is_a?(String) %>\n<% end %>"
},
{
"path": "files/simple/views/layouts/_messages.html.haml",
"chars": 98,
"preview": "- flash.each do |name, msg|\n = content_tag :div, msg, :id => \"flash_#{name}\" if msg.is_a?(String)"
},
{
"path": "files/simple/views/layouts/application.html.erb",
"chars": 778,
"preview": "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrom"
},
{
"path": "files/simple/views/layouts/application.html.haml",
"chars": 544,
"preview": "!!!\n%html\n %head\n %title App_Name\n %meta{:charset => \"utf-8\"}\n %meta{\"http-equiv\" => \"X-UA-Compatible\", :conte"
},
{
"path": "files/twitter-bootstrap/assets/stylesheets/application.css.scss",
"chars": 936,
"preview": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below"
},
{
"path": "files/twitter-bootstrap/views/layouts/_messages.html.erb",
"chars": 249,
"preview": "<% flash.each do |name, msg| %>\n <div class=\"alert alert-<%= name == :notice ? \"success\" : \"error\" %>\">\n <a class=\"c"
},
{
"path": "files/twitter-bootstrap/views/layouts/_messages.html.haml",
"chars": 215,
"preview": "- flash.each do |name, msg|\n %div{:class => \"alert alert-#{name == :notice ? \"success\" : \"error\"}\"}\n %a.close{\"data-"
},
{
"path": "files/twitter-bootstrap/views/layouts/application.html.erb",
"chars": 1143,
"preview": "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrom"
},
{
"path": "files/twitter-bootstrap/views/layouts/application.html.haml",
"chars": 830,
"preview": "!!!\n%html\n %head\n %meta{:charset => \"utf-8\"}\n %meta{\"http-equiv\" => \"X-UA-Compatible\", :content => \"IE=edge,chrom"
},
{
"path": "files/views/layouts/application.html.erb",
"chars": 839,
"preview": "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrom"
},
{
"path": "files/views/layouts/application.html.haml",
"chars": 584,
"preview": "!!!\n%html\n %head\n %title App_Name\n %meta{:charset => \"utf-8\"}\n %meta{\"http-equiv\" => \"X-UA-Compatible\", :conte"
},
{
"path": "files-v2/.rvmrc",
"chars": 2045,
"preview": "#!/usr/bin/env bash\n\n# This is an RVM Project .rvmrc file, used to automatically load the ruby\n# development environment"
},
{
"path": "files-v2/README",
"chars": 317,
"preview": "App_Name\n========================\n\nThis application was generated with the rails_apps_composer gem:\nhttps://github.com/R"
},
{
"path": "files-v2/README.textile",
"chars": 1991,
"preview": "h1. App_Name\n\nThis application was generated with the \"rails_apps_composer\":https://github.com/RailsApps/rails_apps_comp"
},
{
"path": "files-v2/app/assets/stylesheets/application-bootstrap.css.scss",
"chars": 936,
"preview": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below"
},
{
"path": "files-v2/app/assets/stylesheets/application.css.scss",
"chars": 899,
"preview": "/*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below"
},
{
"path": "files-v2/app/views/devise/registrations/edit.html.erb",
"chars": 1021,
"preview": "<h2>Edit <%= resource_name.to_s.humanize %></h2>\n\n<%= form_for(resource, :as => resource_name, :url => registration_path"
},
{
"path": "files-v2/app/views/devise/registrations/edit.html.haml",
"chars": 914,
"preview": "%h2\n Edit #{resource_name.to_s.humanize}\n= form_for(resource, :as => resource_name, :url => registration_path(resource_"
},
{
"path": "files-v2/app/views/devise/registrations/new.html.erb",
"chars": 554,
"preview": "<h2>Sign up</h2>\n\n<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>\n <%="
},
{
"path": "files-v2/app/views/devise/registrations/new.html.haml",
"chars": 495,
"preview": "%h2 Sign up\n= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|\n = devise_error"
},
{
"path": "files-v2/app/views/devise/shared/_links.html.erb",
"chars": 1099,
"preview": "<%- if controller_name != 'sessions' %>\n <%= link_to \"Sign in\", new_session_path(resource_name) %><br />\n<% end -%>\n\n<%"
},
{
"path": "files-v2/app/views/devise/shared/_links.html.haml",
"chars": 958,
"preview": "- if controller_name != 'sessions'\n = link_to \"Sign in\", new_session_path(resource_name)\n %br/\n- if devise_mapping.reg"
},
{
"path": "files-v2/app/views/home/index-subdomains_app.html.erb",
"chars": 169,
"preview": "<h3>Home</h3>\n<% @users.each do |user| %>\n <p><%= #{user.name} profile: #{link_to root_url(:subdomain => user.name), ro"
},
{
"path": "files-v2/app/views/home/index-subdomains_app.html.haml",
"chars": 145,
"preview": "%h3 Home\n- @users.each do |user|\n %br/ \n #{user.name} profile: #{link_to root_url(:subdomain => user.name), root_url(:"
},
{
"path": "files-v2/app/views/home/index.html.erb",
"chars": 96,
"preview": "<h3>Home</h3>\n<% @users.each do |user| %>\n <p>User: <%=link_to user.name, user %></p>\n<% end %>"
},
{
"path": "files-v2/app/views/home/index.html.haml",
"chars": 74,
"preview": "%h3 Home\n- @users.each do |user|\n %p\n User: #{link_to user.name, user}"
},
{
"path": "files-v2/app/views/layouts/_messages-bootstrap.html.erb",
"chars": 249,
"preview": "<% flash.each do |name, msg| %>\n <div class=\"alert alert-<%= name == :notice ? \"success\" : \"error\" %>\">\n <a class=\"c"
},
{
"path": "files-v2/app/views/layouts/_messages-bootstrap.html.haml",
"chars": 215,
"preview": "- flash.each do |name, msg|\n %div{:class => \"alert alert-#{name == :notice ? \"success\" : \"error\"}\"}\n %a.close{\"data-"
},
{
"path": "files-v2/app/views/layouts/_messages.html.erb",
"chars": 117,
"preview": "<% flash.each do |name, msg| %>\n <%= content_tag :div, msg, :id => \"flash_#{name}\" if msg.is_a?(String) %>\n<% end %>"
},
{
"path": "files-v2/app/views/layouts/_messages.html.haml",
"chars": 98,
"preview": "- flash.each do |name, msg|\n = content_tag :div, msg, :id => \"flash_#{name}\" if msg.is_a?(String)"
},
{
"path": "files-v2/app/views/layouts/_navigation-cancan.html.erb",
"chars": 633,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n <%= lin"
},
{
"path": "files-v2/app/views/layouts/_navigation-cancan.html.haml",
"chars": 478,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n = link_to('Logout', dest"
},
{
"path": "files-v2/app/views/layouts/_navigation-devise.html.erb",
"chars": 512,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n <%= lin"
},
{
"path": "files-v2/app/views/layouts/_navigation-devise.html.haml",
"chars": 390,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n = link_to('Logout', dest"
},
{
"path": "files-v2/app/views/layouts/_navigation-omniauth.html.erb",
"chars": 321,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <% if user_signed_in? %>\n <li>\n Logged "
},
{
"path": "files-v2/app/views/layouts/_navigation-omniauth.html.haml",
"chars": 232,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n - if user_signed_in?\n %li\n Logged in as #{current_u"
},
{
"path": "files-v2/app/views/layouts/_navigation-subdomains_app.html.erb",
"chars": 815,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>\n<ul class=\"nav\">\n <li>\n <%= link_to 'Main', root_url(:host ="
},
{
"path": "files-v2/app/views/layouts/_navigation-subdomains_app.html.haml",
"chars": 638,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'\n%ul.nav\n %li\n = link_to 'Main', root_url(:host => request.domain)"
},
{
"path": "files-v2/app/views/layouts/_navigation.html.erb",
"chars": 55,
"preview": "<%= link_to \"App_Name\", root_path, :class => 'brand' %>"
},
{
"path": "files-v2/app/views/layouts/_navigation.html.haml",
"chars": 50,
"preview": "= link_to \"App_Name\", root_path, :class => 'brand'"
},
{
"path": "files-v2/app/views/layouts/application-bootstrap.html.erb",
"chars": 1143,
"preview": "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrom"
},
{
"path": "files-v2/app/views/layouts/application-bootstrap.html.haml",
"chars": 830,
"preview": "!!!\n%html\n %head\n %meta{:charset => \"utf-8\"}\n %meta{\"http-equiv\" => \"X-UA-Compatible\", :content => \"IE=edge,chrom"
},
{
"path": "files-v2/app/views/layouts/application.html.erb",
"chars": 778,
"preview": "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrom"
},
{
"path": "files-v2/app/views/layouts/application.html.haml",
"chars": 544,
"preview": "!!!\n%html\n %head\n %title App_Name\n %meta{:charset => \"utf-8\"}\n %meta{\"http-equiv\" => \"X-UA-Compatible\", :conte"
},
{
"path": "files-v2/app/views/profiles/show-subdomains_app.html.erb",
"chars": 71,
"preview": "<h1>Profile</h1>\n<h3><%= @user.name %></h3>\n<h3><%= @user.email %></h3>"
},
{
"path": "files-v2/app/views/profiles/show-subdomains_app.html.haml",
"chars": 45,
"preview": "%h1 Profile\n%h3= @user.name\n%h3= @user.email\n"
},
{
"path": "files-v2/app/views/users/edit-omniauth.html.erb",
"chars": 130,
"preview": "<%= form_for(@user) do |f| %>\n <%= f.label :email %>\n <%= f.text_field :email %>\n <br />\n <%= f.submit \"Sign in\" %>\n"
},
{
"path": "files-v2/app/views/users/edit-omniauth.html.haml",
"chars": 97,
"preview": "= form_for(@user) do |f|\n = f.label :email\n = f.text_field :email\n %br/\n = f.submit \"Sign in\""
},
{
"path": "files-v2/app/views/users/index.html.erb",
"chars": 178,
"preview": "<h3>Users</h3>\n<ul class=\"users\">\n <% @users.each do |user| %>\n <li>\n <%= link_to user.name, user %> signed up "
},
{
"path": "files-v2/app/views/users/index.html.haml",
"chars": 128,
"preview": "%h3 Users\n%ul.users\n - @users.each do |user|\n %li\n = link_to user.name, user\n signed up #{user.created_at."
},
{
"path": "files-v2/app/views/users/show-subdomains_app.html.erb",
"chars": 184,
"preview": "<p>User: <%= @user.name %></p>\n<p>Email: <%= @user.email if @user.email %></p>\n<p>Profile: <%= #{link_to root_url(:subdo"
},
{
"path": "files-v2/app/views/users/show-subdomains_app.html.haml",
"chars": 163,
"preview": "%p\n User: #{@user.name}\n%p\n Email: #{@user.email if @user.email}\n%p\n Profile: #{link_to root_url(:subdomain => @user."
},
{
"path": "files-v2/app/views/users/show.html.erb",
"chars": 92,
"preview": "<h3>User</h3>\n<p>User: <%= @user.name %></p>\n<p>Email: <%= @user.email if @user.email %></p>"
},
{
"path": "files-v2/app/views/users/show.html.haml",
"chars": 75,
"preview": "%h3 User\n%p\n User: #{@user.name}\n%p\n Email: #{@user.email if @user.email}"
},
{
"path": "files-v2/config/database-mysql.yml",
"chars": 919,
"preview": "# MySQL. Versions 4.1 and 5.0 are recommended.\n# \n# Install the MYSQL driver\n# gem install mysql2\n#\n# Ensure the MySQ"
},
{
"path": "files-v2/config/database-postgresql.yml",
"chars": 1467,
"preview": "# PostgreSQL. Versions 8.2 and up are supported.\n#\n# Install the pg driver:\n# gem install pg\n# On Mac OS X with macpor"
},
{
"path": "files-v2/public/humans.txt",
"chars": 366,
"preview": "/* the humans responsible & colophon */\n/* humanstxt.org */\n\n\n/* TEAM */\n <your title>: <your name>\n Site:\n Twitter:\n"
},
{
"path": "rails-prelaunch-signup-template.rb",
"chars": 94964,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
},
{
"path": "rails3-bootstrap-devise-cancan-template.rb",
"chars": 81309,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
},
{
"path": "rails3-devise-rspec-cucumber-template.rb",
"chars": 81307,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
},
{
"path": "rails3-haml-html5-template.rb",
"chars": 21039,
"preview": "# Application Generator Template\n# Modifies a Rails app to set up Haml with an HTML5 application layout and options for "
},
{
"path": "rails3-mongoid-devise-template.rb",
"chars": 81300,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
},
{
"path": "rails3-mongoid-omniauth-template.rb",
"chars": 81302,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
},
{
"path": "rails3-subdomains-template.rb",
"chars": 81296,
"preview": "# >---------------------------------------------------------------------------<\n#\n# _____ _ _ "
}
]
About this extraction
This page contains the full source code of the RailsApps/rails3-application-templates GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 86 files (559.3 KB), approximately 156.6k tokens, and a symbol index with 138 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.