zsh_dots 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +25 -0
 - data/.gitmodules +3 -0
 - data/.rvmrc +47 -0
 - data/Gemfile +7 -0
 - data/Gemfile.lock +38 -0
 - data/README.md +115 -0
 - data/Rakefile +9 -0
 - data/bin/dots +7 -0
 - data/bin/elocal_nightly.sh +12 -0
 - data/bin/gbrt +42 -0
 - data/bin/git_cwd_info +40 -0
 - data/bin/lein +229 -0
 - data/bin/reattach-to-user-namespace +0 -0
 - data/bin/ssh-copy-id +54 -0
 - data/bin/stock +83 -0
 - data/config/.dot_file +1 -0
 - data/config/aws +0 -0
 - data/config/example.aws.zsh +13 -0
 - data/config/gemrc +9 -0
 - data/config/gitconfig +46 -0
 - data/config/railsrc +2 -0
 - data/config/rspec +2 -0
 - data/config/rvmrc +1 -0
 - data/config/screenrc +1 -0
 - data/config/tmux.conf +6 -0
 - data/config/zlogin +1 -0
 - data/config/zshenv +59 -0
 - data/config/zshrc +8 -0
 - data/etc/mandlebrot.c +59 -0
 - data/etc/rails/composer.yml +30 -0
 - data/etc/rails/ember_template.rb +60 -0
 - data/etc/rails/recipes/haml_views.rb +20 -0
 - data/etc/rails/recipes/html5.rb +84 -0
 - data/etc/rails/recipes/readme_markdown.rb +87 -0
 - data/etc/rails/template.rb +1419 -0
 - data/lib/dots/aliases.zsh +40 -0
 - data/lib/dots/directories.zsh +28 -0
 - data/lib/dots/functions.zsh +41 -0
 - data/lib/dots/plugins.zsh +18 -0
 - data/lib/dots.sh +11 -0
 - data/lib/plugins/aws/aws.plugin.zsh +20 -0
 - data/lib/plugins/bundler/_bundler +82 -0
 - data/lib/plugins/bundler/bundler.plugin.zsh +7 -0
 - data/lib/plugins/git/git.plugin.zsh +126 -0
 - data/lib/plugins/git-flow/git-flow.plugin.zsh +340 -0
 - data/lib/plugins/knife/_knife +183 -0
 - data/lib/plugins/knife/knife.plugin.zsh +1 -0
 - data/lib/plugins/macvim/macvim.plugin.zsh +13 -0
 - data/lib/plugins/osx/_man-preview +5 -0
 - data/lib/plugins/osx/osx.plugin.zsh +101 -0
 - data/lib/plugins/rails3/rails3.plugin.zsh +75 -0
 - data/lib/plugins/rake/rake.plugin.zsh +6 -0
 - data/lib/plugins/ruby/ruby.plugin.zsh +58 -0
 - data/lib/ruby/dots/command.rb +58 -0
 - data/lib/ruby/dots/dot_file.rb +73 -0
 - data/lib/ruby/dots/version.rb +3 -0
 - data/lib/ruby/dots.rb +9 -0
 - data/lib/tasks/db.rake +55 -0
 - data/lib/tasks/dots.rake +32 -0
 - data/spec/integration/command_spec.rb +34 -0
 - data/spec/models/dot_file_spec.rb +45 -0
 - data/spec/spec_helper.rb +6 -0
 - data/vendor/antigen.zsh +251 -0
 - data/vendor/oh-my-zsh/check_for_upgrade.sh +45 -0
 - data/vendor/oh-my-zsh/install.sh +43 -0
 - data/vendor/oh-my-zsh/require_tool.sh +161 -0
 - data/vendor/oh-my-zsh/uninstall.sh +20 -0
 - data/vendor/oh-my-zsh/upgrade.sh +6 -0
 - data/zsh_dots.gemspec +28 -0
 - metadata +163 -0
 
| 
         @@ -0,0 +1,1419 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # >---------------------------------------------------------------------------<
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            #            _____       _ _                              
         
     | 
| 
      
 4 
     | 
    
         
            +
            #           |  __ \     (_) |       /\                    
         
     | 
| 
      
 5 
     | 
    
         
            +
            #           | |__) |__ _ _| |___   /  \   _ __  _ __  ___ 
         
     | 
| 
      
 6 
     | 
    
         
            +
            #           |  _  // _` | | / __| / /\ \ | '_ \| '_ \/ __|
         
     | 
| 
      
 7 
     | 
    
         
            +
            #           | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \
         
     | 
| 
      
 8 
     | 
    
         
            +
            #           |_|  \_\__,_|_|_|___/_/    \_\ .__/| .__/|___/
         
     | 
| 
      
 9 
     | 
    
         
            +
            #                                        | |   | |        
         
     | 
| 
      
 10 
     | 
    
         
            +
            #                                        |_|   |_|
         
     | 
| 
      
 11 
     | 
    
         
            +
            #
         
     | 
| 
      
 12 
     | 
    
         
            +
            #   Template generated by rails_apps_composer. For more information, see:
         
     | 
| 
      
 13 
     | 
    
         
            +
            #   https://github.com/RailsApps/rails_apps_composer/
         
     | 
| 
      
 14 
     | 
    
         
            +
            #   Thank you to Michael Bleigh for leading the way with the RailsWizard gem.
         
     | 
| 
      
 15 
     | 
    
         
            +
            #
         
     | 
| 
      
 16 
     | 
    
         
            +
            # >---------------------------------------------------------------------------<
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            # >----------------------------[ Initial Setup ]------------------------------<
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            initializer 'generators.rb', <<-RUBY
         
     | 
| 
      
 21 
     | 
    
         
            +
            Rails.application.config.generators do |g|
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            @recipes = ["git", "setup", "readme_markdown", "gems", "testing", "auth", "models", "controllers", "views", "haml_views", "routes", "frontend", "html5", "extras"]
         
     | 
| 
      
 26 
     | 
    
         
            +
            @prefs = {:dev_webserver=>"thin", :prod_webserver=>"unicorn", :database=>"postgresql", :templates=>"haml", :unit_test=>"minitest", :integration=>"capybara", :fixtures=>"factory_girl", :frontend=>"bootstrap", :bootstrap=>"sass", :form_builder=>"simpleform", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none"}
         
     | 
| 
      
 27 
     | 
    
         
            +
            @gems = []
         
     | 
| 
      
 28 
     | 
    
         
            +
            @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"], ["auth", "controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["all", "auth", "controllers", "email", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "railsapps", "readme", "routes", "setup", "testing", "views"], ["auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"], ["all", "auth", "controllers", "email", "example", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "setup", "testing", "views"]]
         
     | 
| 
      
 29 
     | 
    
         
            +
            @diagnostics_prefs = [{:railsapps=>"rails3-bootstrap-devise-cancan", :database=>"sqlite", :templates=>"erb", :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", :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-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"}]
         
     | 
| 
      
 30 
     | 
    
         
            +
            diagnostics = {}
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            def recipes; @recipes end
         
     | 
| 
      
 33 
     | 
    
         
            +
            def recipe?(name); @recipes.include?(name) end
         
     | 
| 
      
 34 
     | 
    
         
            +
            def prefs; @prefs end
         
     | 
| 
      
 35 
     | 
    
         
            +
            def prefer(key, value); @prefs[key].eql? value end
         
     | 
| 
      
 36 
     | 
    
         
            +
            def gems; @gems end
         
     | 
| 
      
 37 
     | 
    
         
            +
            def diagnostics_recipes; @diagnostics_recipes end
         
     | 
| 
      
 38 
     | 
    
         
            +
            def diagnostics_prefs; @diagnostics_prefs end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + "  #{text}" end
         
     | 
| 
      
 41 
     | 
    
         
            +
            def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + "  Running #{name} recipe..." end
         
     | 
| 
      
 42 
     | 
    
         
            +
            def say_wizard(text); say_custom(@current_recipe || 'composer', text) end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            def ask_wizard(question)
         
     | 
| 
      
 45 
     | 
    
         
            +
              ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[1m\033[36m" + "  #{question}\033[0m"
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            def yes_wizard?(question)
         
     | 
| 
      
 49 
     | 
    
         
            +
              answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
         
     | 
| 
      
 50 
     | 
    
         
            +
              case answer.downcase
         
     | 
| 
      
 51 
     | 
    
         
            +
                when "yes", "y"
         
     | 
| 
      
 52 
     | 
    
         
            +
                  true
         
     | 
| 
      
 53 
     | 
    
         
            +
                when "no", "n"
         
     | 
| 
      
 54 
     | 
    
         
            +
                  false
         
     | 
| 
      
 55 
     | 
    
         
            +
                else
         
     | 
| 
      
 56 
     | 
    
         
            +
                  yes_wizard?(question)
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            def no_wizard?(question); !yes_wizard?(question) end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            def multiple_choice(question, choices)
         
     | 
| 
      
 63 
     | 
    
         
            +
              say_custom('question', question)
         
     | 
| 
      
 64 
     | 
    
         
            +
              values = {}
         
     | 
| 
      
 65 
     | 
    
         
            +
              choices.each_with_index do |choice,i| 
         
     | 
| 
      
 66 
     | 
    
         
            +
                values[(i + 1).to_s] = choice[1]
         
     | 
| 
      
 67 
     | 
    
         
            +
                say_custom (i + 1).to_s + ')', choice[0]
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
              answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
         
     | 
| 
      
 70 
     | 
    
         
            +
              values[answer]
         
     | 
| 
      
 71 
     | 
    
         
            +
            end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            @current_recipe = nil
         
     | 
| 
      
 74 
     | 
    
         
            +
            @configs = {}
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            @after_blocks = []
         
     | 
| 
      
 77 
     | 
    
         
            +
            def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
         
     | 
| 
      
 78 
     | 
    
         
            +
            @after_everything_blocks = []
         
     | 
| 
      
 79 
     | 
    
         
            +
            def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
         
     | 
| 
      
 80 
     | 
    
         
            +
            @before_configs = {}
         
     | 
| 
      
 81 
     | 
    
         
            +
            def before_config(&block); @before_configs[@current_recipe] = block; end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            def copy_from(source, destination)
         
     | 
| 
      
 84 
     | 
    
         
            +
              begin
         
     | 
| 
      
 85 
     | 
    
         
            +
                remove_file destination
         
     | 
| 
      
 86 
     | 
    
         
            +
                get source, destination
         
     | 
| 
      
 87 
     | 
    
         
            +
              rescue OpenURI::HTTPError
         
     | 
| 
      
 88 
     | 
    
         
            +
                say_wizard "Unable to obtain #{source}"
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            def copy_from_repo(filename, opts = {})
         
     | 
| 
      
 93 
     | 
    
         
            +
              repo = 'https://raw.github.com/RailsApps/rails-composer/master/files/'
         
     | 
| 
      
 94 
     | 
    
         
            +
              repo = opts[:repo] unless opts[:repo].nil?
         
     | 
| 
      
 95 
     | 
    
         
            +
              if (!opts[:prefs].nil?) && (!prefs.has_value? opts[:prefs])
         
     | 
| 
      
 96 
     | 
    
         
            +
                return
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
              source_filename = filename
         
     | 
| 
      
 99 
     | 
    
         
            +
              destination_filename = filename
         
     | 
| 
      
 100 
     | 
    
         
            +
              unless opts[:prefs].nil?
         
     | 
| 
      
 101 
     | 
    
         
            +
                if filename.include? opts[:prefs]
         
     | 
| 
      
 102 
     | 
    
         
            +
                  destination_filename = filename.gsub(/\-#{opts[:prefs]}/, '')
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
              if (prefer :templates, 'haml') && (filename.include? 'views')
         
     | 
| 
      
 106 
     | 
    
         
            +
                remove_file destination_filename
         
     | 
| 
      
 107 
     | 
    
         
            +
                destination_filename = destination_filename.gsub(/.erb/, '.haml')
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
              if (prefer :templates, 'slim') && (filename.include? 'views')
         
     | 
| 
      
 110 
     | 
    
         
            +
                remove_file destination_filename
         
     | 
| 
      
 111 
     | 
    
         
            +
                destination_filename = destination_filename.gsub(/.erb/, '.slim')
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
              begin
         
     | 
| 
      
 114 
     | 
    
         
            +
                remove_file destination_filename
         
     | 
| 
      
 115 
     | 
    
         
            +
                if (prefer :templates, 'haml') && (filename.include? 'views')
         
     | 
| 
      
 116 
     | 
    
         
            +
                  create_file destination_filename, html_to_haml(repo + source_filename)
         
     | 
| 
      
 117 
     | 
    
         
            +
                elsif (prefer :templates, 'slim') && (filename.include? 'views')
         
     | 
| 
      
 118 
     | 
    
         
            +
                  create_file destination_filename, html_to_slim(repo + source_filename)
         
     | 
| 
      
 119 
     | 
    
         
            +
                else
         
     | 
| 
      
 120 
     | 
    
         
            +
                  get repo + source_filename, destination_filename
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
              rescue OpenURI::HTTPError
         
     | 
| 
      
 123 
     | 
    
         
            +
                say_wizard "Unable to obtain #{source_filename} from the repo #{repo}"
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
            end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            def html_to_haml(source)
         
     | 
| 
      
 128 
     | 
    
         
            +
              html = open(source) {|input| input.binmode.read }
         
     | 
| 
      
 129 
     | 
    
         
            +
              Haml::HTML.new(html, :erb => true, :xhtml => true).render
         
     | 
| 
      
 130 
     | 
    
         
            +
            end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            def html_to_slim(source)
         
     | 
| 
      
 133 
     | 
    
         
            +
              html = open(source) {|input| input.binmode.read }
         
     | 
| 
      
 134 
     | 
    
         
            +
              haml = Haml::HTML.new(html, :erb => true, :xhtml => true).render
         
     | 
| 
      
 135 
     | 
    
         
            +
              Haml2Slim.convert!(haml)
         
     | 
| 
      
 136 
     | 
    
         
            +
            end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            if diagnostics_recipes.sort.include? recipes.sort
         
     | 
| 
      
 140 
     | 
    
         
            +
              diagnostics[:recipes] = 'success'
         
     | 
| 
      
 141 
     | 
    
         
            +
              say_wizard("WOOT! The recipes you've selected are known to work together.")
         
     | 
| 
      
 142 
     | 
    
         
            +
            else
         
     | 
| 
      
 143 
     | 
    
         
            +
              diagnostics[:recipes] = 'fail'
         
     | 
| 
      
 144 
     | 
    
         
            +
              say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m")
         
     | 
| 
      
 145 
     | 
    
         
            +
              say_wizard("Help us out by reporting whether this combination works or fails.")
         
     | 
| 
      
 146 
     | 
    
         
            +
              say_wizard("Please open an issue for rails_apps_composer on GitHub.")
         
     | 
| 
      
 147 
     | 
    
         
            +
              say_wizard("Your new application will contain diagnostics in its README file.")
         
     | 
| 
      
 148 
     | 
    
         
            +
              say_wizard("Continuing...")
         
     | 
| 
      
 149 
     | 
    
         
            +
            end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            # this application template only supports Rails version 3.1 and newer
         
     | 
| 
      
 152 
     | 
    
         
            +
            case Rails::VERSION::MAJOR.to_s
         
     | 
| 
      
 153 
     | 
    
         
            +
            when "3"
         
     | 
| 
      
 154 
     | 
    
         
            +
              case Rails::VERSION::MINOR.to_s
         
     | 
| 
      
 155 
     | 
    
         
            +
              when "0"
         
     | 
| 
      
 156 
     | 
    
         
            +
                say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
         
     | 
| 
      
 157 
     | 
    
         
            +
                raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
         
     | 
| 
      
 158 
     | 
    
         
            +
              end
         
     | 
| 
      
 159 
     | 
    
         
            +
            else
         
     | 
| 
      
 160 
     | 
    
         
            +
              say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer."
         
     | 
| 
      
 161 
     | 
    
         
            +
              raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer."
         
     | 
| 
      
 162 
     | 
    
         
            +
            end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
            say_wizard "Using rails_apps_composer recipes to generate an application."
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            # >---------------------------[ Autoload Modules/Classes ]-----------------------------<
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY'
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                config.autoload_paths += %W(#{config.root}/lib)
         
     | 
| 
      
 171 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 172 
     | 
    
         
            +
            end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
            # >---------------------------------[ Recipes ]----------------------------------<
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            # >----------------------------------[ git ]----------------------------------<
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
            @current_recipe = "git"
         
     | 
| 
      
 180 
     | 
    
         
            +
            @before_configs["git"].call if @before_configs["git"]
         
     | 
| 
      
 181 
     | 
    
         
            +
            say_recipe 'git'
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 187 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/git.rb
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
            ## Git
         
     | 
| 
      
 190 
     | 
    
         
            +
            say_wizard "initialize git"
         
     | 
| 
      
 191 
     | 
    
         
            +
            prefs[:git] = true unless prefs.has_key? :git
         
     | 
| 
      
 192 
     | 
    
         
            +
            if prefer :git, true
         
     | 
| 
      
 193 
     | 
    
         
            +
              copy_from 'https://raw.github.com/RailsApps/rails-composer/master/files/gitignore.txt', '.gitignore'
         
     | 
| 
      
 194 
     | 
    
         
            +
              git :init
         
     | 
| 
      
 195 
     | 
    
         
            +
              git :add => '.'
         
     | 
| 
      
 196 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: initial commit'"
         
     | 
| 
      
 197 
     | 
    
         
            +
            end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
            # >---------------------------------[ setup ]---------------------------------<
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
            @current_recipe = "setup"
         
     | 
| 
      
 203 
     | 
    
         
            +
            @before_configs["setup"].call if @before_configs["setup"]
         
     | 
| 
      
 204 
     | 
    
         
            +
            say_recipe 'setup'
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 210 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/setup.rb
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            ## Ruby on Rails
         
     | 
| 
      
 213 
     | 
    
         
            +
            say_wizard "You are using Ruby version #{RUBY_VERSION}."
         
     | 
| 
      
 214 
     | 
    
         
            +
            say_wizard "You are using Rails version #{Rails::VERSION::STRING}."
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
            ## Is sqlite3 in the Gemfile?
         
     | 
| 
      
 217 
     | 
    
         
            +
            gemfile = File.read(destination_root() + '/Gemfile')
         
     | 
| 
      
 218 
     | 
    
         
            +
            sqlite_detected = gemfile.include? 'sqlite3'
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            ## Web Server
         
     | 
| 
      
 221 
     | 
    
         
            +
            prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"], 
         
     | 
| 
      
 222 
     | 
    
         
            +
              ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :dev_webserver
         
     | 
| 
      
 223 
     | 
    
         
            +
            webserver = multiple_choice "Web server for production?", [["Same as development", "same"], 
         
     | 
| 
      
 224 
     | 
    
         
            +
              ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"]] unless prefs.has_key? :prod_webserver
         
     | 
| 
      
 225 
     | 
    
         
            +
            if webserver == 'same'
         
     | 
| 
      
 226 
     | 
    
         
            +
              case prefs[:dev_webserver]
         
     | 
| 
      
 227 
     | 
    
         
            +
                when 'thin'
         
     | 
| 
      
 228 
     | 
    
         
            +
                  prefs[:prod_webserver] = 'thin'
         
     | 
| 
      
 229 
     | 
    
         
            +
                when 'unicorn'
         
     | 
| 
      
 230 
     | 
    
         
            +
                  prefs[:prod_webserver] = 'unicorn'
         
     | 
| 
      
 231 
     | 
    
         
            +
                when 'puma'
         
     | 
| 
      
 232 
     | 
    
         
            +
                  prefs[:prod_webserver] = 'puma'
         
     | 
| 
      
 233 
     | 
    
         
            +
              end
         
     | 
| 
      
 234 
     | 
    
         
            +
            else
         
     | 
| 
      
 235 
     | 
    
         
            +
              prefs[:prod_webserver] = webserver
         
     | 
| 
      
 236 
     | 
    
         
            +
            end
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
            ## Database Adapter
         
     | 
| 
      
 239 
     | 
    
         
            +
            prefs[:database] = multiple_choice "Database used in development?", [["SQLite", "sqlite"], ["PostgreSQL", "postgresql"], 
         
     | 
| 
      
 240 
     | 
    
         
            +
              ["MySQL", "mysql"], ["MongoDB", "mongodb"]] unless prefs.has_key? :database
         
     | 
| 
      
 241 
     | 
    
         
            +
            case prefs[:database]
         
     | 
| 
      
 242 
     | 
    
         
            +
              when 'mongodb'
         
     | 
| 
      
 243 
     | 
    
         
            +
                unless sqlite_detected
         
     | 
| 
      
 244 
     | 
    
         
            +
                  prefs[:orm] = multiple_choice "How will you connect to MongoDB?", [["Mongoid","mongoid"]] unless prefs.has_key? :orm
         
     | 
| 
      
 245 
     | 
    
         
            +
                else
         
     | 
| 
      
 246 
     | 
    
         
            +
                  say_wizard "WARNING! SQLite gem detected in the Gemfile"
         
     | 
| 
      
 247 
     | 
    
         
            +
                  say_wizard "If you wish to use MongoDB you must skip Active Record."
         
     | 
| 
      
 248 
     | 
    
         
            +
                  say_wizard "When launching rails_apps_composer, choose 'skip Active Record'."
         
     | 
| 
      
 249 
     | 
    
         
            +
                  say_wizard "If using an application template, use the '-O' flag as in 'rails new foo -O'."
         
     | 
| 
      
 250 
     | 
    
         
            +
                  prefs[:fail] = multiple_choice "Abort or continue?", [["abort", "abort"], ["continue", "continue"]]
         
     | 
| 
      
 251 
     | 
    
         
            +
                  if prefer :fail, 'abort'
         
     | 
| 
      
 252 
     | 
    
         
            +
                    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"
         
     | 
| 
      
 253 
     | 
    
         
            +
                  end
         
     | 
| 
      
 254 
     | 
    
         
            +
                end
         
     | 
| 
      
 255 
     | 
    
         
            +
            end
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
            ## Template Engine
         
     | 
| 
      
 258 
     | 
    
         
            +
            prefs[:templates] = multiple_choice "Template engine?", [["ERB", "erb"], ["Haml", "haml"], ["Slim", "slim"]] unless prefs.has_key? :templates
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
            ## Testing Framework
         
     | 
| 
      
 261 
     | 
    
         
            +
            if recipes.include? 'testing'
         
     | 
| 
      
 262 
     | 
    
         
            +
              prefs[:unit_test] = multiple_choice "Unit testing?", [["Test::Unit", "test_unit"], ["RSpec", "rspec"]] unless prefs.has_key? :unit_test
         
     | 
| 
      
 263 
     | 
    
         
            +
              prefs[:integration] = multiple_choice "Integration testing?", [["RSpec with Capybara", "capybara"], 
         
     | 
| 
      
 264 
     | 
    
         
            +
                ["Cucumber with Capybara", "cucumber"], ["Turnip with Capybara", "turnip"]] unless prefs.has_key? :integration
         
     | 
| 
      
 265 
     | 
    
         
            +
              prefs[:fixtures] = multiple_choice "Fixture replacement?", [["None","none"], ["Factory Girl","factory_girl"], ["Machinist","machinist"]] unless prefs.has_key? :fixtures
         
     | 
| 
      
 266 
     | 
    
         
            +
            end
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
            ## Front-end Framework
         
     | 
| 
      
 269 
     | 
    
         
            +
            if recipes.include? 'frontend'
         
     | 
| 
      
 270 
     | 
    
         
            +
              prefs[:frontend] = multiple_choice "Front-end framework?", [["None", "none"], ["Twitter Bootstrap", "bootstrap"], 
         
     | 
| 
      
 271 
     | 
    
         
            +
                ["Zurb Foundation", "foundation"], ["Skeleton", "skeleton"], ["Just normalize CSS for consistent styling", "normalize"]] unless prefs.has_key? :frontend
         
     | 
| 
      
 272 
     | 
    
         
            +
              if prefer :frontend, 'bootstrap'
         
     | 
| 
      
 273 
     | 
    
         
            +
                prefs[:bootstrap] = multiple_choice "Twitter Bootstrap version?", [["Twitter Bootstrap (Less)", "less"],
         
     | 
| 
      
 274 
     | 
    
         
            +
                  ["Twitter Bootstrap (Sass)", "sass"]] unless prefs.has_key? :bootstrap
         
     | 
| 
      
 275 
     | 
    
         
            +
              end
         
     | 
| 
      
 276 
     | 
    
         
            +
            end
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
            ## Email
         
     | 
| 
      
 279 
     | 
    
         
            +
            if recipes.include? 'email'
         
     | 
| 
      
 280 
     | 
    
         
            +
              prefs[:email] = multiple_choice "Add support for sending email?", [["None", "none"], ["Gmail","gmail"], ["SMTP","smtp"], 
         
     | 
| 
      
 281 
     | 
    
         
            +
                ["SendGrid","sendgrid"], ["Mandrill","mandrill"]] unless prefs.has_key? :email
         
     | 
| 
      
 282 
     | 
    
         
            +
            else
         
     | 
| 
      
 283 
     | 
    
         
            +
              prefs[:email] = 'none'
         
     | 
| 
      
 284 
     | 
    
         
            +
            end
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
            ## Authentication and Authorization
         
     | 
| 
      
 287 
     | 
    
         
            +
            if recipes.include? 'auth'
         
     | 
| 
      
 288 
     | 
    
         
            +
              prefs[:authentication] = multiple_choice "Authentication?", [["None", "none"], ["Devise", "devise"], ["OmniAuth", "omniauth"]] unless prefs.has_key? :authentication
         
     | 
| 
      
 289 
     | 
    
         
            +
              case prefs[:authentication]
         
     | 
| 
      
 290 
     | 
    
         
            +
                when 'devise'
         
     | 
| 
      
 291 
     | 
    
         
            +
                  if prefer :orm, 'mongoid'
         
     | 
| 
      
 292 
     | 
    
         
            +
                    prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"]] unless prefs.has_key? :devise_modules
         
     | 
| 
      
 293 
     | 
    
         
            +
                  else
         
     | 
| 
      
 294 
     | 
    
         
            +
                    prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], ["Devise with Confirmable module","confirmable"], 
         
     | 
| 
      
 295 
     | 
    
         
            +
                      ["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules
         
     | 
| 
      
 296 
     | 
    
         
            +
                  end
         
     | 
| 
      
 297 
     | 
    
         
            +
                when 'omniauth'
         
     | 
| 
      
 298 
     | 
    
         
            +
                  prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], 
         
     | 
| 
      
 299 
     | 
    
         
            +
                    ["LinkedIn", "linkedin"], ["Google-Oauth-2", "google-oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider
         
     | 
| 
      
 300 
     | 
    
         
            +
              end
         
     | 
| 
      
 301 
     | 
    
         
            +
              prefs[:authorization] = multiple_choice "Authorization?", [["None", "none"], ["CanCan with Rolify", "cancan"]] unless prefs.has_key? :authorization
         
     | 
| 
      
 302 
     | 
    
         
            +
            end
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
            ## MVC
         
     | 
| 
      
 305 
     | 
    
         
            +
            if (recipes.include? 'models') && (recipes.include? 'controllers') && (recipes.include? 'views') && (recipes.include? 'routes')
         
     | 
| 
      
 306 
     | 
    
         
            +
              if prefer :authorization, 'cancan'
         
     | 
| 
      
 307 
     | 
    
         
            +
                prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 
         
     | 
| 
      
 308 
     | 
    
         
            +
                  ["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Admin Dashboard", "admin_app"]] unless prefs.has_key? :starter_app
         
     | 
| 
      
 309 
     | 
    
         
            +
              elsif prefer :authentication, 'devise'
         
     | 
| 
      
 310 
     | 
    
         
            +
                if prefer :orm, 'mongoid'
         
     | 
| 
      
 311 
     | 
    
         
            +
                  prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 
         
     | 
| 
      
 312 
     | 
    
         
            +
                    ["Home Page, User Accounts", "users_app"], ["Home Page, User Accounts, Subdomains", "subdomains_app"]] unless prefs.has_key? :starter_app
         
     | 
| 
      
 313 
     | 
    
         
            +
                else
         
     | 
| 
      
 314 
     | 
    
         
            +
                  prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 
         
     | 
| 
      
 315 
     | 
    
         
            +
                    ["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
         
     | 
| 
      
 316 
     | 
    
         
            +
                end
         
     | 
| 
      
 317 
     | 
    
         
            +
              elsif prefer :authentication, 'omniauth'
         
     | 
| 
      
 318 
     | 
    
         
            +
                prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"], 
         
     | 
| 
      
 319 
     | 
    
         
            +
                  ["Home Page, User Accounts", "users_app"]] unless prefs.has_key? :starter_app
         
     | 
| 
      
 320 
     | 
    
         
            +
              else
         
     | 
| 
      
 321 
     | 
    
         
            +
                prefs[:starter_app] = multiple_choice "Install a starter app?", [["None", "none"], ["Home Page", "home_app"]] unless prefs.has_key? :starter_app
         
     | 
| 
      
 322 
     | 
    
         
            +
              end
         
     | 
| 
      
 323 
     | 
    
         
            +
              if (recipes.include? 'prelaunch') && (prefer :authentication, 'devise') && (prefer :authorization, 'cancan')
         
     | 
| 
      
 324 
     | 
    
         
            +
                prefs[:prelaunch_app] = multiple_choice "Install a prelaunch app?", [["None", "none"], ["Prelaunch Signup App", "signup_app"]]
         
     | 
| 
      
 325 
     | 
    
         
            +
                if prefs[:prelaunch_app] == 'signup_app'
         
     | 
| 
      
 326 
     | 
    
         
            +
                  prefs[:devise_modules] = 'confirmable'
         
     | 
| 
      
 327 
     | 
    
         
            +
                  prefs[:bulkmail] = multiple_choice "Send news and announcements with a mail service?", [["None", "none"], ["MailChimp","mailchimp"]]
         
     | 
| 
      
 328 
     | 
    
         
            +
                  if prefer :git, true
         
     | 
| 
      
 329 
     | 
    
         
            +
                    prefs[:prelaunch_branch] = multiple_choice "Git branch for the prelaunch app?", [["wip (work-in-progress)", "wip"], ["master", "master"], ["prelaunch", "prelaunch"], ["staging", "staging"]]
         
     | 
| 
      
 330 
     | 
    
         
            +
                    if prefs[:prelaunch_branch] == 'master'
         
     | 
| 
      
 331 
     | 
    
         
            +
                      prefs[:main_branch] = multiple_choice "Git branch for the main app?", [["None (delete)", "none"], ["wip (work-in-progress)", "wip"], ["edge", "edge"]]
         
     | 
| 
      
 332 
     | 
    
         
            +
                    end
         
     | 
| 
      
 333 
     | 
    
         
            +
                  end
         
     | 
| 
      
 334 
     | 
    
         
            +
                end
         
     | 
| 
      
 335 
     | 
    
         
            +
              end
         
     | 
| 
      
 336 
     | 
    
         
            +
            end
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
            # >----------------------------[ readme_markdown ]----------------------------<
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
            @current_recipe = "readme_markdown"
         
     | 
| 
      
 342 
     | 
    
         
            +
            @before_configs["readme_markdown"].call if @before_configs["readme_markdown"]
         
     | 
| 
      
 343 
     | 
    
         
            +
            say_recipe 'readme_markdown'
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
      
 346 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 347 
     | 
    
         
            +
             
     | 
| 
      
 348 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 349 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/readme.rb
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
      
 351 
     | 
    
         
            +
            after_everything do
         
     | 
| 
      
 352 
     | 
    
         
            +
              say_wizard "recipe running after everything"
         
     | 
| 
      
 353 
     | 
    
         
            +
              
         
     | 
| 
      
 354 
     | 
    
         
            +
              # remove default READMEs
         
     | 
| 
      
 355 
     | 
    
         
            +
              %w{
         
     | 
| 
      
 356 
     | 
    
         
            +
                README
         
     | 
| 
      
 357 
     | 
    
         
            +
                README.rdoc
         
     | 
| 
      
 358 
     | 
    
         
            +
                doc/README_FOR_APP
         
     | 
| 
      
 359 
     | 
    
         
            +
              }.each { |file| remove_file file }
         
     | 
| 
      
 360 
     | 
    
         
            +
             
     | 
| 
      
 361 
     | 
    
         
            +
              # add placeholder READMEs and humans.txt file
         
     | 
| 
      
 362 
     | 
    
         
            +
              copy_from_repo 'public/humans.txt'
         
     | 
| 
      
 363 
     | 
    
         
            +
              copy_from_repo 'README'
         
     | 
| 
      
 364 
     | 
    
         
            +
              copy_from_repo 'README.md'
         
     | 
| 
      
 365 
     | 
    
         
            +
              gsub_file "README", /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 366 
     | 
    
         
            +
              gsub_file "README.md", /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 367 
     | 
    
         
            +
             
     | 
| 
      
 368 
     | 
    
         
            +
              # Diagnostics
         
     | 
| 
      
 369 
     | 
    
         
            +
              gsub_file "README.md", /recipes that are known/, "recipes that are NOT known" if diagnostics[:recipes] == 'fail'
         
     | 
| 
      
 370 
     | 
    
         
            +
              gsub_file "README.md", /preferences that are known/, "preferences that are NOT known" if diagnostics[:prefs] == 'fail'
         
     | 
| 
      
 371 
     | 
    
         
            +
              gsub_file "README.md", /RECIPES/, recipes.sort.inspect
         
     | 
| 
      
 372 
     | 
    
         
            +
              gsub_file "README.md", /PREFERENCES/, prefs.inspect
         
     | 
| 
      
 373 
     | 
    
         
            +
              gsub_file "README", /RECIPES/, recipes.sort.inspect
         
     | 
| 
      
 374 
     | 
    
         
            +
              gsub_file "README", /PREFERENCES/, prefs.inspect
         
     | 
| 
      
 375 
     | 
    
         
            +
              
         
     | 
| 
      
 376 
     | 
    
         
            +
              # Ruby on Rails
         
     | 
| 
      
 377 
     | 
    
         
            +
              gsub_file "README.md", /\* Ruby/, "* Ruby version #{RUBY_VERSION}"
         
     | 
| 
      
 378 
     | 
    
         
            +
              gsub_file "README.md", /\* Rails/, "* Rails version #{Rails::VERSION::STRING}"
         
     | 
| 
      
 379 
     | 
    
         
            +
                
         
     | 
| 
      
 380 
     | 
    
         
            +
              # Database
         
     | 
| 
      
 381 
     | 
    
         
            +
              gsub_file "README.md", /SQLite/, "PostgreSQL" if prefer :database, 'postgresql'
         
     | 
| 
      
 382 
     | 
    
         
            +
              gsub_file "README.md", /SQLite/, "MySQL" if prefer :database, 'mysql'
         
     | 
| 
      
 383 
     | 
    
         
            +
              gsub_file "README.md", /SQLite/, "MongoDB" if prefer :database, 'mongodb'
         
     | 
| 
      
 384 
     | 
    
         
            +
              gsub_file "README.md", /ActiveRecord/, "the Mongoid ORM" if prefer :orm, 'mongoid'
         
     | 
| 
      
 385 
     | 
    
         
            +
             
     | 
| 
      
 386 
     | 
    
         
            +
              # Template Engine
         
     | 
| 
      
 387 
     | 
    
         
            +
              gsub_file "README.md", /ERB/, "Haml" if prefer :templates, 'haml'
         
     | 
| 
      
 388 
     | 
    
         
            +
              gsub_file "README.md", /ERB/, "Slim" if prefer :templates, 'slim'
         
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
              # Testing Framework
         
     | 
| 
      
 391 
     | 
    
         
            +
              gsub_file "README.md", /Test::Unit/, "RSpec" if prefer :unit_test, 'rspec'
         
     | 
| 
      
 392 
     | 
    
         
            +
              gsub_file "README.md", /RSpec/, "RSpec and Cucumber" if prefer :integration, 'cucumber'
         
     | 
| 
      
 393 
     | 
    
         
            +
              gsub_file "README.md", /RSpec/, "RSpec and Factory Girl" if prefer :fixtures, 'factory_girl'
         
     | 
| 
      
 394 
     | 
    
         
            +
              gsub_file "README.md", /RSpec/, "RSpec and Machinist" if prefer :fixtures, 'machinist'
         
     | 
| 
      
 395 
     | 
    
         
            +
             
     | 
| 
      
 396 
     | 
    
         
            +
              # Front-end Framework
         
     | 
| 
      
 397 
     | 
    
         
            +
              gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Sass)" if prefer :bootstrap, 'sass'
         
     | 
| 
      
 398 
     | 
    
         
            +
              gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Twitter Bootstrap (Less)" if prefer :bootstrap, 'less'
         
     | 
| 
      
 399 
     | 
    
         
            +
              gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Zurb Foundation" if prefer :frontend, 'foundation'
         
     | 
| 
      
 400 
     | 
    
         
            +
              gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Skeleton" if prefer :frontend, 'skeleton'
         
     | 
| 
      
 401 
     | 
    
         
            +
              gsub_file "README.md", /Front-end Framework: None/, "Front-end Framework: Normalized CSS" if prefer :frontend, 'normalize'
         
     | 
| 
      
 402 
     | 
    
         
            +
             
     | 
| 
      
 403 
     | 
    
         
            +
              # Form Builder
         
     | 
| 
      
 404 
     | 
    
         
            +
              gsub_file "README.md", /Form Builder: None/, "Form Builder: SimpleForm" if prefer :form_builder, 'simple_form'
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
              # Email
         
     | 
| 
      
 407 
     | 
    
         
            +
              unless prefer :email, 'none'
         
     | 
| 
      
 408 
     | 
    
         
            +
                gsub_file "README.md", /Gmail/, "SMTP" if prefer :email, 'smtp'
         
     | 
| 
      
 409 
     | 
    
         
            +
                gsub_file "README.md", /Gmail/, "SendGrid" if prefer :email, 'sendgrid'
         
     | 
| 
      
 410 
     | 
    
         
            +
                gsub_file "README.md", /Gmail/, "Mandrill" if prefer :email, 'mandrill'
         
     | 
| 
      
 411 
     | 
    
         
            +
              else
         
     | 
| 
      
 412 
     | 
    
         
            +
                gsub_file "README.md", /h2. Email/, ""
         
     | 
| 
      
 413 
     | 
    
         
            +
                gsub_file "README.md", /The application is configured to send email using a Gmail account./, ""
         
     | 
| 
      
 414 
     | 
    
         
            +
              end
         
     | 
| 
      
 415 
     | 
    
         
            +
             
     | 
| 
      
 416 
     | 
    
         
            +
              # Authentication and Authorization
         
     | 
| 
      
 417 
     | 
    
         
            +
              gsub_file "README.md", /Authentication: None/, "Authentication: Devise" if prefer :authentication, 'devise'
         
     | 
| 
      
 418 
     | 
    
         
            +
              gsub_file "README.md", /Authentication: None/, "Authentication: OmniAuth" if prefer :authentication, 'omniauth'
         
     | 
| 
      
 419 
     | 
    
         
            +
              gsub_file "README.md", /Authorization: None/, "Authorization: CanCan" if prefer :authorization, 'cancan'
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 422 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: add README files'" if prefer :git, true
         
     | 
| 
      
 423 
     | 
    
         
            +
              
         
     | 
| 
      
 424 
     | 
    
         
            +
            end # after_everything
         
     | 
| 
      
 425 
     | 
    
         
            +
             
     | 
| 
      
 426 
     | 
    
         
            +
             
     | 
| 
      
 427 
     | 
    
         
            +
            # >---------------------------------[ gems ]----------------------------------<
         
     | 
| 
      
 428 
     | 
    
         
            +
             
     | 
| 
      
 429 
     | 
    
         
            +
            @current_recipe = "gems"
         
     | 
| 
      
 430 
     | 
    
         
            +
            @before_configs["gems"].call if @before_configs["gems"]
         
     | 
| 
      
 431 
     | 
    
         
            +
            say_recipe 'gems'
         
     | 
| 
      
 432 
     | 
    
         
            +
             
     | 
| 
      
 433 
     | 
    
         
            +
             
     | 
| 
      
 434 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 437 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/gems.rb
         
     | 
| 
      
 438 
     | 
    
         
            +
             
     | 
| 
      
 439 
     | 
    
         
            +
            ### GEMFILE ###
         
     | 
| 
      
 440 
     | 
    
         
            +
             
     | 
| 
      
 441 
     | 
    
         
            +
            ## Ruby on Rails
         
     | 
| 
      
 442 
     | 
    
         
            +
            insert_into_file 'Gemfile', "ruby '1.9.3'\n", :before => "gem 'rails', '3.2.6'" if prefer :deploy, 'heroku'
         
     | 
| 
      
 443 
     | 
    
         
            +
             
     | 
| 
      
 444 
     | 
    
         
            +
            ## Web Server
         
     | 
| 
      
 445 
     | 
    
         
            +
            gem 'thin', '>= 1.4.1', :group => [:development, :test] if prefer :dev_webserver, 'thin'
         
     | 
| 
      
 446 
     | 
    
         
            +
            gem 'unicorn', '>= 4.3.1', :group => [:development, :test] if prefer :dev_webserver, 'unicorn'
         
     | 
| 
      
 447 
     | 
    
         
            +
            gem 'puma', '>= 1.5.0', :group => [:development, :test] if prefer :dev_webserver, 'puma'
         
     | 
| 
      
 448 
     | 
    
         
            +
            gem 'thin', '>= 1.4.1', :group => :production if prefer :prod_webserver, 'thin'
         
     | 
| 
      
 449 
     | 
    
         
            +
            gem 'unicorn', '>= 4.3.1', :group => :production if prefer :prod_webserver, 'unicorn'
         
     | 
| 
      
 450 
     | 
    
         
            +
            gem 'puma', '>= 1.6.1', :group => :production if prefer :prod_webserver, 'puma'
         
     | 
| 
      
 451 
     | 
    
         
            +
             
     | 
| 
      
 452 
     | 
    
         
            +
            ## Database Adapter
         
     | 
| 
      
 453 
     | 
    
         
            +
            gsub_file 'Gemfile', /gem 'sqlite3'\n/, '' unless prefer :database, 'sqlite'
         
     | 
| 
      
 454 
     | 
    
         
            +
            gem 'mongoid', '>= 3.0.3' if prefer :orm, 'mongoid'
         
     | 
| 
      
 455 
     | 
    
         
            +
            gem 'pg', '>= 0.14.0' if prefer :database, 'postgresql'
         
     | 
| 
      
 456 
     | 
    
         
            +
            gem 'mysql2', '>= 0.3.11' if prefer :database, 'mysql'
         
     | 
| 
      
 457 
     | 
    
         
            +
            copy_from_repo 'config/database-postgresql.yml', :prefs => 'postgresql'
         
     | 
| 
      
 458 
     | 
    
         
            +
            copy_from_repo 'config/database-mysql.yml', :prefs => 'mysql'
         
     | 
| 
      
 459 
     | 
    
         
            +
             
     | 
| 
      
 460 
     | 
    
         
            +
            ## Template Engine
         
     | 
| 
      
 461 
     | 
    
         
            +
            if prefer :templates, 'haml'
         
     | 
| 
      
 462 
     | 
    
         
            +
              gem 'haml', '>= 3.1.7'
         
     | 
| 
      
 463 
     | 
    
         
            +
              gem 'haml-rails', '>= 0.3.4', :group => :development
         
     | 
| 
      
 464 
     | 
    
         
            +
              # hpricot and ruby_parser are needed for conversion of HTML to Haml
         
     | 
| 
      
 465 
     | 
    
         
            +
              gem 'hpricot', '>= 0.8.6', :group => :development
         
     | 
| 
      
 466 
     | 
    
         
            +
              gem 'ruby_parser', '>= 2.3.1', :group => :development
         
     | 
| 
      
 467 
     | 
    
         
            +
            end
         
     | 
| 
      
 468 
     | 
    
         
            +
            if prefer :templates, 'slim'
         
     | 
| 
      
 469 
     | 
    
         
            +
              gem 'slim', '>= 1.2.2'
         
     | 
| 
      
 470 
     | 
    
         
            +
              gem 'haml2slim', '>= 0.4.6', :group => :development
         
     | 
| 
      
 471 
     | 
    
         
            +
              # Haml is needed for conversion of HTML to Slim
         
     | 
| 
      
 472 
     | 
    
         
            +
              gem 'haml', '>= 3.1.6', :group => :development
         
     | 
| 
      
 473 
     | 
    
         
            +
              gem 'haml-rails', '>= 0.3.4', :group => :development
         
     | 
| 
      
 474 
     | 
    
         
            +
              gem 'hpricot', '>= 0.8.6', :group => :development
         
     | 
| 
      
 475 
     | 
    
         
            +
              gem 'ruby_parser', '>= 2.3.1', :group => :development
         
     | 
| 
      
 476 
     | 
    
         
            +
            end
         
     | 
| 
      
 477 
     | 
    
         
            +
             
     | 
| 
      
 478 
     | 
    
         
            +
            ## Testing Framework
         
     | 
| 
      
 479 
     | 
    
         
            +
            if prefer :unit_test, 'rspec'
         
     | 
| 
      
 480 
     | 
    
         
            +
              gem 'rspec-rails', '>= 2.11.0', :group => [:development, :test]
         
     | 
| 
      
 481 
     | 
    
         
            +
              gem 'capybara', '>= 1.1.2', :group => :test
         
     | 
| 
      
 482 
     | 
    
         
            +
              if prefer :orm, 'mongoid'
         
     | 
| 
      
 483 
     | 
    
         
            +
                # use the database_cleaner gem to reset the test database
         
     | 
| 
      
 484 
     | 
    
         
            +
                gem 'database_cleaner', '>= 0.8.0', :group => :test
         
     | 
| 
      
 485 
     | 
    
         
            +
                # include RSpec matchers from the mongoid-rspec gem
         
     | 
| 
      
 486 
     | 
    
         
            +
                gem 'mongoid-rspec', '>= 1.4.6', :group => :test
         
     | 
| 
      
 487 
     | 
    
         
            +
              end
         
     | 
| 
      
 488 
     | 
    
         
            +
              gem 'email_spec', '>= 1.2.1', :group => :test unless prefer :email, 'none'
         
     | 
| 
      
 489 
     | 
    
         
            +
            end
         
     | 
| 
      
 490 
     | 
    
         
            +
            if prefer :integration, 'cucumber'
         
     | 
| 
      
 491 
     | 
    
         
            +
              gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
         
     | 
| 
      
 492 
     | 
    
         
            +
              gem 'database_cleaner', '>= 0.8.0', :group => :test unless prefer :orm, 'mongoid'
         
     | 
| 
      
 493 
     | 
    
         
            +
              gem 'launchy', '>= 2.1.2', :group => :test
         
     | 
| 
      
 494 
     | 
    
         
            +
            end
         
     | 
| 
      
 495 
     | 
    
         
            +
            gem 'turnip', '>= 1.0.0', :group => :test if prefer :integration, 'turnip'
         
     | 
| 
      
 496 
     | 
    
         
            +
            gem 'factory_girl_rails', '>= 4.0.0', :group => [:development, :test] if prefer :fixtures, 'factory_girl'
         
     | 
| 
      
 497 
     | 
    
         
            +
            gem 'machinist', '>= 2.0', :group => :test if prefer :fixtures, 'machinist'
         
     | 
| 
      
 498 
     | 
    
         
            +
             
     | 
| 
      
 499 
     | 
    
         
            +
            ## Front-end Framework
         
     | 
| 
      
 500 
     | 
    
         
            +
            gem 'bootstrap-sass', '>= 2.0.4.0' if prefer :bootstrap, 'sass'
         
     | 
| 
      
 501 
     | 
    
         
            +
            gem 'zurb-foundation', '>= 3.0.8' if prefer :frontend, 'foundation'
         
     | 
| 
      
 502 
     | 
    
         
            +
            if prefer :bootstrap, 'less'
         
     | 
| 
      
 503 
     | 
    
         
            +
              gem 'twitter-bootstrap-rails', '>= 2.1.1', :group => :assets
         
     | 
| 
      
 504 
     | 
    
         
            +
              # install gem 'therubyracer' to use Less
         
     | 
| 
      
 505 
     | 
    
         
            +
              gem 'therubyracer', '>= 0.10.2', :group => :assets, :platform => :ruby
         
     | 
| 
      
 506 
     | 
    
         
            +
            end
         
     | 
| 
      
 507 
     | 
    
         
            +
             
     | 
| 
      
 508 
     | 
    
         
            +
            ## Email
         
     | 
| 
      
 509 
     | 
    
         
            +
            gem 'sendgrid', '>= 1.0.1' if prefer :email, 'sendgrid'
         
     | 
| 
      
 510 
     | 
    
         
            +
            gem 'hominid', '>= 3.0.5' if prefer :email, 'mandrill'
         
     | 
| 
      
 511 
     | 
    
         
            +
             
     | 
| 
      
 512 
     | 
    
         
            +
            ## Authentication (Devise)
         
     | 
| 
      
 513 
     | 
    
         
            +
            gem 'devise', '>= 2.1.2' if prefer :authentication, 'devise'
         
     | 
| 
      
 514 
     | 
    
         
            +
            gem 'devise_invitable', '>= 1.0.3' if prefer :devise_modules, 'invitable'
         
     | 
| 
      
 515 
     | 
    
         
            +
             
     | 
| 
      
 516 
     | 
    
         
            +
            ## Authentication (OmniAuth)
         
     | 
| 
      
 517 
     | 
    
         
            +
            gem 'omniauth', '>= 1.1.0' if prefer :authentication, 'omniauth'
         
     | 
| 
      
 518 
     | 
    
         
            +
            gem 'omniauth-twitter' if prefer :omniauth_provider, 'twitter'
         
     | 
| 
      
 519 
     | 
    
         
            +
            gem 'omniauth-facebook' if prefer :omniauth_provider, 'facebook'
         
     | 
| 
      
 520 
     | 
    
         
            +
            gem 'omniauth-github' if prefer :omniauth_provider, 'github'
         
     | 
| 
      
 521 
     | 
    
         
            +
            gem 'omniauth-linkedin' if prefer :omniauth_provider, 'linkedin'
         
     | 
| 
      
 522 
     | 
    
         
            +
            gem 'omniauth-google-oauth2' if prefer :omniauth_provider, 'google-oauth2'
         
     | 
| 
      
 523 
     | 
    
         
            +
            gem 'omniauth-tumblr' if prefer :omniauth_provider, 'tumblr'
         
     | 
| 
      
 524 
     | 
    
         
            +
             
     | 
| 
      
 525 
     | 
    
         
            +
            ## Authorization 
         
     | 
| 
      
 526 
     | 
    
         
            +
            if prefer :authorization, 'cancan'
         
     | 
| 
      
 527 
     | 
    
         
            +
              gem 'cancan', '>= 1.6.8'
         
     | 
| 
      
 528 
     | 
    
         
            +
              gem 'rolify', '>= 3.2.0'
         
     | 
| 
      
 529 
     | 
    
         
            +
            end
         
     | 
| 
      
 530 
     | 
    
         
            +
             
     | 
| 
      
 531 
     | 
    
         
            +
            ## Signup App 
         
     | 
| 
      
 532 
     | 
    
         
            +
            if prefer :prelaunch_app, 'signup_app'
         
     | 
| 
      
 533 
     | 
    
         
            +
              gem 'google_visualr', '>= 2.1.2'
         
     | 
| 
      
 534 
     | 
    
         
            +
              gem 'jquery-datatables-rails', '>= 1.10.0'
         
     | 
| 
      
 535 
     | 
    
         
            +
            end
         
     | 
| 
      
 536 
     | 
    
         
            +
             
     | 
| 
      
 537 
     | 
    
         
            +
            ## Gems from a defaults file or added interactively
         
     | 
| 
      
 538 
     | 
    
         
            +
            gems.each do |g|
         
     | 
| 
      
 539 
     | 
    
         
            +
              gem g
         
     | 
| 
      
 540 
     | 
    
         
            +
            end
         
     | 
| 
      
 541 
     | 
    
         
            +
             
     | 
| 
      
 542 
     | 
    
         
            +
            ## Git
         
     | 
| 
      
 543 
     | 
    
         
            +
            git :add => '.' if prefer :git, true
         
     | 
| 
      
 544 
     | 
    
         
            +
            git :commit => "-aqm 'rails_apps_composer: Gemfile'" if prefer :git, true
         
     | 
| 
      
 545 
     | 
    
         
            +
             
     | 
| 
      
 546 
     | 
    
         
            +
            ### GENERATORS ###
         
     | 
| 
      
 547 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 548 
     | 
    
         
            +
              ## Database
         
     | 
| 
      
 549 
     | 
    
         
            +
              generate 'mongoid:config' if prefer :orm, 'mongoid'
         
     | 
| 
      
 550 
     | 
    
         
            +
              remove_file 'config/database.yml' if prefer :orm, 'mongoid'
         
     | 
| 
      
 551 
     | 
    
         
            +
              ## Git
         
     | 
| 
      
 552 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 553 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: generators'" if prefer :git, true
         
     | 
| 
      
 554 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 555 
     | 
    
         
            +
             
     | 
| 
      
 556 
     | 
    
         
            +
             
     | 
| 
      
 557 
     | 
    
         
            +
            # >--------------------------------[ testing ]--------------------------------<
         
     | 
| 
      
 558 
     | 
    
         
            +
             
     | 
| 
      
 559 
     | 
    
         
            +
            @current_recipe = "testing"
         
     | 
| 
      
 560 
     | 
    
         
            +
            @before_configs["testing"].call if @before_configs["testing"]
         
     | 
| 
      
 561 
     | 
    
         
            +
            say_recipe 'testing'
         
     | 
| 
      
 562 
     | 
    
         
            +
             
     | 
| 
      
 563 
     | 
    
         
            +
             
     | 
| 
      
 564 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 565 
     | 
    
         
            +
             
     | 
| 
      
 566 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 567 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/testing.rb
         
     | 
| 
      
 568 
     | 
    
         
            +
             
     | 
| 
      
 569 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 570 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 571 
     | 
    
         
            +
              ### RSPEC ###
         
     | 
| 
      
 572 
     | 
    
         
            +
              if prefer :unit_test, 'rspec'
         
     | 
| 
      
 573 
     | 
    
         
            +
                say_wizard "recipe installing RSpec"
         
     | 
| 
      
 574 
     | 
    
         
            +
                generate 'rspec:install'
         
     | 
| 
      
 575 
     | 
    
         
            +
                unless prefer :email, 'none'
         
     | 
| 
      
 576 
     | 
    
         
            +
                  generate 'email_spec:steps'
         
     | 
| 
      
 577 
     | 
    
         
            +
                  inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
         
     | 
| 
      
 578 
     | 
    
         
            +
                  inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
         
     | 
| 
      
 579 
     | 
    
         
            +
              config.include(EmailSpec::Helpers)
         
     | 
| 
      
 580 
     | 
    
         
            +
              config.include(EmailSpec::Matchers)
         
     | 
| 
      
 581 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 582 
     | 
    
         
            +
                  end
         
     | 
| 
      
 583 
     | 
    
         
            +
                end
         
     | 
| 
      
 584 
     | 
    
         
            +
                run 'rm -rf test/' # Removing test folder (not needed for RSpec)
         
     | 
| 
      
 585 
     | 
    
         
            +
                inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
         
     | 
| 
      
 586 
     | 
    
         
            +
             
     | 
| 
      
 587 
     | 
    
         
            +
                # don't generate RSpec tests for views and helpers
         
     | 
| 
      
 588 
     | 
    
         
            +
                config.generators do |g|
         
     | 
| 
      
 589 
     | 
    
         
            +
                  g.view_specs false
         
     | 
| 
      
 590 
     | 
    
         
            +
                  g.helper_specs false
         
     | 
| 
      
 591 
     | 
    
         
            +
                  #{"g.fixture_replacement :machinist" if prefer :fixtures, 'machinist'}
         
     | 
| 
      
 592 
     | 
    
         
            +
                end
         
     | 
| 
      
 593 
     | 
    
         
            +
             
     | 
| 
      
 594 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 595 
     | 
    
         
            +
                end
         
     | 
| 
      
 596 
     | 
    
         
            +
                ## RSPEC AND MONGOID
         
     | 
| 
      
 597 
     | 
    
         
            +
                if prefer :orm, 'mongoid'
         
     | 
| 
      
 598 
     | 
    
         
            +
                  # remove ActiveRecord artifacts
         
     | 
| 
      
 599 
     | 
    
         
            +
                  gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
         
     | 
| 
      
 600 
     | 
    
         
            +
                  gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
         
     | 
| 
      
 601 
     | 
    
         
            +
                  # reset your application database to a pristine state during testing
         
     | 
| 
      
 602 
     | 
    
         
            +
                  inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
         
     | 
| 
      
 603 
     | 
    
         
            +
                  <<-RUBY
         
     | 
| 
      
 604 
     | 
    
         
            +
              \n
         
     | 
| 
      
 605 
     | 
    
         
            +
              require 'database_cleaner'
         
     | 
| 
      
 606 
     | 
    
         
            +
              config.before(:suite) do
         
     | 
| 
      
 607 
     | 
    
         
            +
                DatabaseCleaner.strategy = :truncation
         
     | 
| 
      
 608 
     | 
    
         
            +
                DatabaseCleaner.orm = "mongoid"
         
     | 
| 
      
 609 
     | 
    
         
            +
              end
         
     | 
| 
      
 610 
     | 
    
         
            +
             
     | 
| 
      
 611 
     | 
    
         
            +
              config.before(:each) do
         
     | 
| 
      
 612 
     | 
    
         
            +
                DatabaseCleaner.clean
         
     | 
| 
      
 613 
     | 
    
         
            +
              end
         
     | 
| 
      
 614 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 615 
     | 
    
         
            +
                  end
         
     | 
| 
      
 616 
     | 
    
         
            +
                  # remove either possible occurrence of "require rails/test_unit/railtie"
         
     | 
| 
      
 617 
     | 
    
         
            +
                  gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
         
     | 
| 
      
 618 
     | 
    
         
            +
                  gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
         
     | 
| 
      
 619 
     | 
    
         
            +
                  # configure RSpec to use matchers from the mongoid-rspec gem
         
     | 
| 
      
 620 
     | 
    
         
            +
                  create_file 'spec/support/mongoid.rb' do
         
     | 
| 
      
 621 
     | 
    
         
            +
                  <<-RUBY
         
     | 
| 
      
 622 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 623 
     | 
    
         
            +
              config.include Mongoid::Matchers
         
     | 
| 
      
 624 
     | 
    
         
            +
            end
         
     | 
| 
      
 625 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 626 
     | 
    
         
            +
                  end
         
     | 
| 
      
 627 
     | 
    
         
            +
                end
         
     | 
| 
      
 628 
     | 
    
         
            +
                ## RSPEC AND DEVISE
         
     | 
| 
      
 629 
     | 
    
         
            +
                if prefer :authentication, 'devise'
         
     | 
| 
      
 630 
     | 
    
         
            +
                  # add Devise test helpers
         
     | 
| 
      
 631 
     | 
    
         
            +
                  create_file 'spec/support/devise.rb' do
         
     | 
| 
      
 632 
     | 
    
         
            +
                  <<-RUBY
         
     | 
| 
      
 633 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 634 
     | 
    
         
            +
              config.include Devise::TestHelpers, :type => :controller
         
     | 
| 
      
 635 
     | 
    
         
            +
            end
         
     | 
| 
      
 636 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 637 
     | 
    
         
            +
                  end
         
     | 
| 
      
 638 
     | 
    
         
            +
                end
         
     | 
| 
      
 639 
     | 
    
         
            +
              end
         
     | 
| 
      
 640 
     | 
    
         
            +
              ### CUCUMBER ###
         
     | 
| 
      
 641 
     | 
    
         
            +
              if prefer :integration, 'cucumber'
         
     | 
| 
      
 642 
     | 
    
         
            +
                say_wizard "recipe installing Cucumber"
         
     | 
| 
      
 643 
     | 
    
         
            +
                generate "cucumber:install --capybara#{' --rspec' if prefer :unit_test, 'rspec'}#{' -D' if prefer :orm, 'mongoid'}"
         
     | 
| 
      
 644 
     | 
    
         
            +
                # make it easy to run Cucumber for single features without adding "--require features" to the command line
         
     | 
| 
      
 645 
     | 
    
         
            +
                gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
         
     | 
| 
      
 646 
     | 
    
         
            +
                unless prefer :email, 'none'
         
     | 
| 
      
 647 
     | 
    
         
            +
                  create_file 'features/support/email_spec.rb' do <<-RUBY
         
     | 
| 
      
 648 
     | 
    
         
            +
            require 'email_spec/cucumber'
         
     | 
| 
      
 649 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 650 
     | 
    
         
            +
                  end      
         
     | 
| 
      
 651 
     | 
    
         
            +
                end
         
     | 
| 
      
 652 
     | 
    
         
            +
                ## CUCUMBER AND MONGOID
         
     | 
| 
      
 653 
     | 
    
         
            +
                if prefer :orm, 'mongoid'
         
     | 
| 
      
 654 
     | 
    
         
            +
                  gsub_file 'features/support/env.rb', /transaction/, "truncation"
         
     | 
| 
      
 655 
     | 
    
         
            +
                  inject_into_file 'features/support/env.rb', :after => 'begin' do
         
     | 
| 
      
 656 
     | 
    
         
            +
                    "\n  DatabaseCleaner.orm = 'mongoid'"
         
     | 
| 
      
 657 
     | 
    
         
            +
                  end
         
     | 
| 
      
 658 
     | 
    
         
            +
                end
         
     | 
| 
      
 659 
     | 
    
         
            +
              end
         
     | 
| 
      
 660 
     | 
    
         
            +
              ## TURNIP
         
     | 
| 
      
 661 
     | 
    
         
            +
              if prefer :integration, 'turnip'
         
     | 
| 
      
 662 
     | 
    
         
            +
                append_to_file '.rspec', '-r turnip/rspec'
         
     | 
| 
      
 663 
     | 
    
         
            +
                inject_into_file 'spec/spec_helper.rb', "require 'turnip/capybara'\n", :after => "require 'rspec/rails'\n"
         
     | 
| 
      
 664 
     | 
    
         
            +
                create_file 'spec/acceptance/steps/.gitkeep'
         
     | 
| 
      
 665 
     | 
    
         
            +
              end
         
     | 
| 
      
 666 
     | 
    
         
            +
              ## FIXTURE REPLACEMENTS
         
     | 
| 
      
 667 
     | 
    
         
            +
              if prefer :fixtures, 'machinist'
         
     | 
| 
      
 668 
     | 
    
         
            +
                say_wizard "generating blueprints file for 'machinist'"
         
     | 
| 
      
 669 
     | 
    
         
            +
                generate 'machinist:install'
         
     | 
| 
      
 670 
     | 
    
         
            +
              end
         
     | 
| 
      
 671 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 672 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 673 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: testing framework'" if prefer :git, true
         
     | 
| 
      
 674 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 675 
     | 
    
         
            +
             
     | 
| 
      
 676 
     | 
    
         
            +
            after_everything do
         
     | 
| 
      
 677 
     | 
    
         
            +
              say_wizard "recipe running after everything"
         
     | 
| 
      
 678 
     | 
    
         
            +
              ### RSPEC ###
         
     | 
| 
      
 679 
     | 
    
         
            +
              if prefer :unit_test, 'rspec'
         
     | 
| 
      
 680 
     | 
    
         
            +
                if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
         
     | 
| 
      
 681 
     | 
    
         
            +
                  say_wizard "copying RSpec files from the rails3-devise-rspec-cucumber examples"
         
     | 
| 
      
 682 
     | 
    
         
            +
                  repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
         
     | 
| 
      
 683 
     | 
    
         
            +
                  copy_from_repo 'spec/factories/users.rb', :repo => repo
         
     | 
| 
      
 684 
     | 
    
         
            +
                  gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 685 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
         
     | 
| 
      
 686 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
         
     | 
| 
      
 687 
     | 
    
         
            +
                  copy_from_repo 'spec/models/user_spec.rb', :repo => repo
         
     | 
| 
      
 688 
     | 
    
         
            +
                  remove_file 'spec/views/home/index.html.erb_spec.rb'
         
     | 
| 
      
 689 
     | 
    
         
            +
                  remove_file 'spec/views/home/index.html.haml_spec.rb'
         
     | 
| 
      
 690 
     | 
    
         
            +
                  remove_file 'spec/views/users/show.html.erb_spec.rb'
         
     | 
| 
      
 691 
     | 
    
         
            +
                  remove_file 'spec/views/users/show.html.haml_spec.rb'
         
     | 
| 
      
 692 
     | 
    
         
            +
                  remove_file 'spec/helpers/home_helper_spec.rb'
         
     | 
| 
      
 693 
     | 
    
         
            +
                  remove_file 'spec/helpers/users_helper_spec.rb'
         
     | 
| 
      
 694 
     | 
    
         
            +
                end
         
     | 
| 
      
 695 
     | 
    
         
            +
                if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
         
     | 
| 
      
 696 
     | 
    
         
            +
                  say_wizard "copying RSpec files from the rails3-bootstrap-devise-cancan examples"
         
     | 
| 
      
 697 
     | 
    
         
            +
                  repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
         
     | 
| 
      
 698 
     | 
    
         
            +
                  copy_from_repo 'spec/factories/users.rb', :repo => repo
         
     | 
| 
      
 699 
     | 
    
         
            +
                  gsub_file 'spec/factories/users.rb', /# confirmed_at/, "confirmed_at" if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 700 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
         
     | 
| 
      
 701 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
         
     | 
| 
      
 702 
     | 
    
         
            +
                  copy_from_repo 'spec/models/user_spec.rb', :repo => repo
         
     | 
| 
      
 703 
     | 
    
         
            +
                  remove_file 'spec/views/home/index.html.erb_spec.rb'
         
     | 
| 
      
 704 
     | 
    
         
            +
                  remove_file 'spec/views/home/index.html.haml_spec.rb'
         
     | 
| 
      
 705 
     | 
    
         
            +
                  remove_file 'spec/views/users/show.html.erb_spec.rb'
         
     | 
| 
      
 706 
     | 
    
         
            +
                  remove_file 'spec/views/users/show.html.haml_spec.rb'
         
     | 
| 
      
 707 
     | 
    
         
            +
                  remove_file 'spec/helpers/home_helper_spec.rb'
         
     | 
| 
      
 708 
     | 
    
         
            +
                  remove_file 'spec/helpers/users_helper_spec.rb'
         
     | 
| 
      
 709 
     | 
    
         
            +
                end
         
     | 
| 
      
 710 
     | 
    
         
            +
                ## RSPEC AND OMNIAUTH
         
     | 
| 
      
 711 
     | 
    
         
            +
                if (prefer :authentication, 'omniauth') && (prefer :starter_app, 'users_app')
         
     | 
| 
      
 712 
     | 
    
         
            +
                  say_wizard "copying RSpec files from the rails3-mongoid-omniauth examples"
         
     | 
| 
      
 713 
     | 
    
         
            +
                  repo = 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 714 
     | 
    
         
            +
                  copy_from_repo 'spec/spec_helper.rb', :repo => repo
         
     | 
| 
      
 715 
     | 
    
         
            +
                  copy_from_repo 'spec/factories/users.rb', :repo => repo
         
     | 
| 
      
 716 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/sessions_controller_spec.rb', :repo => repo
         
     | 
| 
      
 717 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
         
     | 
| 
      
 718 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/users_controller_spec.rb', :repo => repo
         
     | 
| 
      
 719 
     | 
    
         
            +
                  copy_from_repo 'spec/models/user_spec.rb', :repo => repo
         
     | 
| 
      
 720 
     | 
    
         
            +
                end
         
     | 
| 
      
 721 
     | 
    
         
            +
                ## GIT
         
     | 
| 
      
 722 
     | 
    
         
            +
                git :add => '.' if prefer :git, true
         
     | 
| 
      
 723 
     | 
    
         
            +
                git :commit => "-aqm 'rails_apps_composer: rspec files'" if prefer :git, true
         
     | 
| 
      
 724 
     | 
    
         
            +
              end
         
     | 
| 
      
 725 
     | 
    
         
            +
              ### CUCUMBER ###
         
     | 
| 
      
 726 
     | 
    
         
            +
              if prefer :integration, 'cucumber'
         
     | 
| 
      
 727 
     | 
    
         
            +
                ## CUCUMBER AND DEVISE
         
     | 
| 
      
 728 
     | 
    
         
            +
                if (prefer :authentication, 'devise') && (prefer :starter_app, 'users_app')
         
     | 
| 
      
 729 
     | 
    
         
            +
                  say_wizard "copying Cucumber scenarios from the rails3-devise-rspec-cucumber examples"
         
     | 
| 
      
 730 
     | 
    
         
            +
                  repo = 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
         
     | 
| 
      
 731 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
         
     | 
| 
      
 732 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_in.feature', :repo => repo
         
     | 
| 
      
 733 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_out.feature', :repo => repo
         
     | 
| 
      
 734 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_up.feature', :repo => repo
         
     | 
| 
      
 735 
     | 
    
         
            +
                  copy_from_repo 'features/users/user_edit.feature', :repo => repo
         
     | 
| 
      
 736 
     | 
    
         
            +
                  copy_from_repo 'features/users/user_show.feature', :repo => repo
         
     | 
| 
      
 737 
     | 
    
         
            +
                  copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
         
     | 
| 
      
 738 
     | 
    
         
            +
                  copy_from_repo 'features/support/paths.rb', :repo => repo
         
     | 
| 
      
 739 
     | 
    
         
            +
                  if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 740 
     | 
    
         
            +
                    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."
         
     | 
| 
      
 741 
     | 
    
         
            +
                    inject_into_file 'features/users/sign_in.feature', :before => '    Scenario: User signs in successfully' do
         
     | 
| 
      
 742 
     | 
    
         
            +
            <<-RUBY
         
     | 
| 
      
 743 
     | 
    
         
            +
              Scenario: User has not confirmed account
         
     | 
| 
      
 744 
     | 
    
         
            +
                Given I exist as an unconfirmed user
         
     | 
| 
      
 745 
     | 
    
         
            +
                And I am not logged in
         
     | 
| 
      
 746 
     | 
    
         
            +
                When I sign in with valid credentials
         
     | 
| 
      
 747 
     | 
    
         
            +
                Then I see an unconfirmed account message
         
     | 
| 
      
 748 
     | 
    
         
            +
                And I should be signed out
         
     | 
| 
      
 749 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 750 
     | 
    
         
            +
                    end
         
     | 
| 
      
 751 
     | 
    
         
            +
                  end
         
     | 
| 
      
 752 
     | 
    
         
            +
                end
         
     | 
| 
      
 753 
     | 
    
         
            +
                if (prefer :authentication, 'devise') && (prefer :starter_app, 'admin_app')
         
     | 
| 
      
 754 
     | 
    
         
            +
                  say_wizard "copying Cucumber scenarios from the rails3-bootstrap-devise-cancan examples"
         
     | 
| 
      
 755 
     | 
    
         
            +
                  repo = 'https://raw.github.com/RailsApps/rails3-bootstrap-devise-cancan/master/'
         
     | 
| 
      
 756 
     | 
    
         
            +
                  copy_from_repo 'spec/controllers/home_controller_spec.rb', :repo => repo
         
     | 
| 
      
 757 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_in.feature', :repo => repo
         
     | 
| 
      
 758 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_out.feature', :repo => repo
         
     | 
| 
      
 759 
     | 
    
         
            +
                  copy_from_repo 'features/users/sign_up.feature', :repo => repo
         
     | 
| 
      
 760 
     | 
    
         
            +
                  copy_from_repo 'features/users/user_edit.feature', :repo => repo
         
     | 
| 
      
 761 
     | 
    
         
            +
                  copy_from_repo 'features/users/user_show.feature', :repo => repo
         
     | 
| 
      
 762 
     | 
    
         
            +
                  copy_from_repo 'features/step_definitions/user_steps.rb', :repo => repo
         
     | 
| 
      
 763 
     | 
    
         
            +
                  copy_from_repo 'features/support/paths.rb', :repo => repo
         
     | 
| 
      
 764 
     | 
    
         
            +
                  if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 765 
     | 
    
         
            +
                    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."
         
     | 
| 
      
 766 
     | 
    
         
            +
                    inject_into_file 'features/users/sign_in.feature', :before => '    Scenario: User signs in successfully' do
         
     | 
| 
      
 767 
     | 
    
         
            +
            <<-RUBY
         
     | 
| 
      
 768 
     | 
    
         
            +
              Scenario: User has not confirmed account
         
     | 
| 
      
 769 
     | 
    
         
            +
                Given I exist as an unconfirmed user
         
     | 
| 
      
 770 
     | 
    
         
            +
                And I am not logged in
         
     | 
| 
      
 771 
     | 
    
         
            +
                When I sign in with valid credentials
         
     | 
| 
      
 772 
     | 
    
         
            +
                Then I see an unconfirmed account message
         
     | 
| 
      
 773 
     | 
    
         
            +
                And I should be signed out
         
     | 
| 
      
 774 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 775 
     | 
    
         
            +
                    end
         
     | 
| 
      
 776 
     | 
    
         
            +
                  end
         
     | 
| 
      
 777 
     | 
    
         
            +
                end
         
     | 
| 
      
 778 
     | 
    
         
            +
                ## GIT
         
     | 
| 
      
 779 
     | 
    
         
            +
                git :add => '.' if prefer :git, true
         
     | 
| 
      
 780 
     | 
    
         
            +
                git :commit => "-aqm 'rails_apps_composer: cucumber files'" if prefer :git, true
         
     | 
| 
      
 781 
     | 
    
         
            +
              end
         
     | 
| 
      
 782 
     | 
    
         
            +
            end # after_everything
         
     | 
| 
      
 783 
     | 
    
         
            +
             
     | 
| 
      
 784 
     | 
    
         
            +
             
     | 
| 
      
 785 
     | 
    
         
            +
            # >---------------------------------[ auth ]----------------------------------<
         
     | 
| 
      
 786 
     | 
    
         
            +
             
     | 
| 
      
 787 
     | 
    
         
            +
            @current_recipe = "auth"
         
     | 
| 
      
 788 
     | 
    
         
            +
            @before_configs["auth"].call if @before_configs["auth"]
         
     | 
| 
      
 789 
     | 
    
         
            +
            say_recipe 'auth'
         
     | 
| 
      
 790 
     | 
    
         
            +
             
     | 
| 
      
 791 
     | 
    
         
            +
             
     | 
| 
      
 792 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 793 
     | 
    
         
            +
             
     | 
| 
      
 794 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 795 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/auth.rb
         
     | 
| 
      
 796 
     | 
    
         
            +
             
     | 
| 
      
 797 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 798 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 799 
     | 
    
         
            +
              ### DEVISE ###
         
     | 
| 
      
 800 
     | 
    
         
            +
              if prefer :authentication, 'devise'
         
     | 
| 
      
 801 
     | 
    
         
            +
                # Prevent logging of password_confirmation
         
     | 
| 
      
 802 
     | 
    
         
            +
                gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
         
     | 
| 
      
 803 
     | 
    
         
            +
                generate 'devise:install'
         
     | 
| 
      
 804 
     | 
    
         
            +
                generate 'devise_invitable:install' if prefer :devise_modules, 'invitable'
         
     | 
| 
      
 805 
     | 
    
         
            +
                generate 'devise user'
         
     | 
| 
      
 806 
     | 
    
         
            +
                ## DEVISE AND CUCUMBER
         
     | 
| 
      
 807 
     | 
    
         
            +
                if prefer :integration, 'cucumber'
         
     | 
| 
      
 808 
     | 
    
         
            +
                  # Cucumber wants to test GET requests not DELETE requests for destroy_user_session_path
         
     | 
| 
      
 809 
     | 
    
         
            +
                  # (see https://github.com/RailsApps/rails3-devise-rspec-cucumber/issues/3)
         
     | 
| 
      
 810 
     | 
    
         
            +
                  gsub_file 'config/initializers/devise.rb', 'config.sign_out_via = :delete', 'config.sign_out_via = Rails.env.test? ? :get : :delete'
         
     | 
| 
      
 811 
     | 
    
         
            +
                end
         
     | 
| 
      
 812 
     | 
    
         
            +
                ## DEVISE MODULES
         
     | 
| 
      
 813 
     | 
    
         
            +
                if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 814 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /:registerable,/, ":registerable, :confirmable,"
         
     | 
| 
      
 815 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /:remember_me/, ':remember_me, :confirmed_at'
         
     | 
| 
      
 816 
     | 
    
         
            +
                  if prefer :orm, 'mongoid'
         
     | 
| 
      
 817 
     | 
    
         
            +
                    gsub_file 'app/models/user.rb', /# field :confirmation_token/, "field :confirmation_token"
         
     | 
| 
      
 818 
     | 
    
         
            +
                    gsub_file 'app/models/user.rb', /# field :confirmed_at/, "field :confirmed_at"
         
     | 
| 
      
 819 
     | 
    
         
            +
                    gsub_file 'app/models/user.rb', /# field :confirmation_sent_at/, "field :confirmation_sent_at"
         
     | 
| 
      
 820 
     | 
    
         
            +
                    gsub_file 'app/models/user.rb', /# field :unconfirmed_email/, "field :unconfirmed_email"
         
     | 
| 
      
 821 
     | 
    
         
            +
                  end
         
     | 
| 
      
 822 
     | 
    
         
            +
                end
         
     | 
| 
      
 823 
     | 
    
         
            +
                if prefer :devise_modules, 'invitable'
         
     | 
| 
      
 824 
     | 
    
         
            +
                  if prefer :orm, 'mongoid'
         
     | 
| 
      
 825 
     | 
    
         
            +
                    gsub_file 'app/models/user.rb', /\bend\s*\Z/ do
         
     | 
| 
      
 826 
     | 
    
         
            +
              <<-RUBY
         
     | 
| 
      
 827 
     | 
    
         
            +
              #invitable
         
     | 
| 
      
 828 
     | 
    
         
            +
              field :invitation_token, :type => String
         
     | 
| 
      
 829 
     | 
    
         
            +
              field :invitation_sent_at, :type => Time
         
     | 
| 
      
 830 
     | 
    
         
            +
              field :invitation_accepted_at, :type => Time
         
     | 
| 
      
 831 
     | 
    
         
            +
              field :invitation_limit, :type => Integer
         
     | 
| 
      
 832 
     | 
    
         
            +
              field :invited_by_id, :type => String
         
     | 
| 
      
 833 
     | 
    
         
            +
              field :invited_by_type, :type => String
         
     | 
| 
      
 834 
     | 
    
         
            +
            end
         
     | 
| 
      
 835 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 836 
     | 
    
         
            +
                    end
         
     | 
| 
      
 837 
     | 
    
         
            +
                  end
         
     | 
| 
      
 838 
     | 
    
         
            +
                end    
         
     | 
| 
      
 839 
     | 
    
         
            +
              end
         
     | 
| 
      
 840 
     | 
    
         
            +
              ### OMNIAUTH ###
         
     | 
| 
      
 841 
     | 
    
         
            +
              if prefer :authentication, 'omniauth'
         
     | 
| 
      
 842 
     | 
    
         
            +
                # Don't use single-quote-style-heredoc: we want interpolation.
         
     | 
| 
      
 843 
     | 
    
         
            +
                create_file 'config/initializers/omniauth.rb' do <<-RUBY
         
     | 
| 
      
 844 
     | 
    
         
            +
            Rails.application.config.middleware.use OmniAuth::Builder do
         
     | 
| 
      
 845 
     | 
    
         
            +
              provider :#{prefs[:omniauth_provider]}, ENV['OMNIAUTH_PROVIDER_KEY'], ENV['OMNIAUTH_PROVIDER_SECRET']
         
     | 
| 
      
 846 
     | 
    
         
            +
            end
         
     | 
| 
      
 847 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 848 
     | 
    
         
            +
                end
         
     | 
| 
      
 849 
     | 
    
         
            +
              end
         
     | 
| 
      
 850 
     | 
    
         
            +
              ### CANCAN ###
         
     | 
| 
      
 851 
     | 
    
         
            +
              if prefer :authorization, 'cancan'
         
     | 
| 
      
 852 
     | 
    
         
            +
                generate 'cancan:ability'
         
     | 
| 
      
 853 
     | 
    
         
            +
                if prefer :starter_app, 'admin_app'
         
     | 
| 
      
 854 
     | 
    
         
            +
                  # Limit access to the users#index page
         
     | 
| 
      
 855 
     | 
    
         
            +
                  inject_into_file 'app/models/ability.rb', :after => "def initialize(user)\n" do <<-RUBY
         
     | 
| 
      
 856 
     | 
    
         
            +
                user ||= User.new # guest user (not logged in)
         
     | 
| 
      
 857 
     | 
    
         
            +
                if user.has_role? :admin
         
     | 
| 
      
 858 
     | 
    
         
            +
                  can :manage, :all
         
     | 
| 
      
 859 
     | 
    
         
            +
                end
         
     | 
| 
      
 860 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 861 
     | 
    
         
            +
                  end
         
     | 
| 
      
 862 
     | 
    
         
            +
                end
         
     | 
| 
      
 863 
     | 
    
         
            +
              end
         
     | 
| 
      
 864 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 865 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 866 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: authentication and authorization'" if prefer :git, true
         
     | 
| 
      
 867 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 868 
     | 
    
         
            +
             
     | 
| 
      
 869 
     | 
    
         
            +
             
     | 
| 
      
 870 
     | 
    
         
            +
            # >--------------------------------[ models ]---------------------------------<
         
     | 
| 
      
 871 
     | 
    
         
            +
             
     | 
| 
      
 872 
     | 
    
         
            +
            @current_recipe = "models"
         
     | 
| 
      
 873 
     | 
    
         
            +
            @before_configs["models"].call if @before_configs["models"]
         
     | 
| 
      
 874 
     | 
    
         
            +
            say_recipe 'models'
         
     | 
| 
      
 875 
     | 
    
         
            +
             
     | 
| 
      
 876 
     | 
    
         
            +
             
     | 
| 
      
 877 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 878 
     | 
    
         
            +
             
     | 
| 
      
 879 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 880 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/models.rb
         
     | 
| 
      
 881 
     | 
    
         
            +
             
     | 
| 
      
 882 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 883 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 884 
     | 
    
         
            +
              ### DEVISE ###
         
     | 
| 
      
 885 
     | 
    
         
            +
              if prefer :authentication, 'devise'
         
     | 
| 
      
 886 
     | 
    
         
            +
                if prefer :orm, 'mongoid'
         
     | 
| 
      
 887 
     | 
    
         
            +
                  copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-devise/master/' if prefer :orm, 'mongoid'
         
     | 
| 
      
 888 
     | 
    
         
            +
                else
         
     | 
| 
      
 889 
     | 
    
         
            +
                  generate 'migration AddNameToUsers name:string'
         
     | 
| 
      
 890 
     | 
    
         
            +
                  if (prefer :devise_modules, 'confirmable') || (prefer :devise_modules, 'invitable')
         
     | 
| 
      
 891 
     | 
    
         
            +
                    generate 'migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string'
         
     | 
| 
      
 892 
     | 
    
         
            +
                  end
         
     | 
| 
      
 893 
     | 
    
         
            +
                  copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
         
     | 
| 
      
 894 
     | 
    
         
            +
                end
         
     | 
| 
      
 895 
     | 
    
         
            +
              end
         
     | 
| 
      
 896 
     | 
    
         
            +
              ### OMNIAUTH ###
         
     | 
| 
      
 897 
     | 
    
         
            +
              if prefer :authentication, 'omniauth'
         
     | 
| 
      
 898 
     | 
    
         
            +
                if prefer :orm, 'mongoid'
         
     | 
| 
      
 899 
     | 
    
         
            +
                  copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 900 
     | 
    
         
            +
                else
         
     | 
| 
      
 901 
     | 
    
         
            +
                  generate 'model User name:string email:string provider:string uid:string'
         
     | 
| 
      
 902 
     | 
    
         
            +
                  run 'bundle exec rake db:migrate'
         
     | 
| 
      
 903 
     | 
    
         
            +
                  copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 904 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /class User/, 'class User < ActiveRecord::Base'
         
     | 
| 
      
 905 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /^\s*include Mongoid::Document\n/, ''
         
     | 
| 
      
 906 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /^\s*field.*\n/, ''
         
     | 
| 
      
 907 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /^\s*# run 'rake db:mongoid:create_indexes' to create indexes\n/, ''
         
     | 
| 
      
 908 
     | 
    
         
            +
                  gsub_file 'app/models/user.rb', /^\s*index\(\{ email: 1 \}, \{ unique: true, background: true \}\)\n/, ''
         
     | 
| 
      
 909 
     | 
    
         
            +
                end
         
     | 
| 
      
 910 
     | 
    
         
            +
              end
         
     | 
| 
      
 911 
     | 
    
         
            +
              ### SUBDOMAINS ###
         
     | 
| 
      
 912 
     | 
    
         
            +
              copy_from_repo 'app/models/user.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains'
         
     | 
| 
      
 913 
     | 
    
         
            +
              ### AUTHORIZATION (insert 'rolify' after User model is created) ###
         
     | 
| 
      
 914 
     | 
    
         
            +
              if prefer :authorization, 'cancan'
         
     | 
| 
      
 915 
     | 
    
         
            +
                unless prefer :orm, 'mongoid'
         
     | 
| 
      
 916 
     | 
    
         
            +
                  generate 'rolify:role Role User'
         
     | 
| 
      
 917 
     | 
    
         
            +
                else
         
     | 
| 
      
 918 
     | 
    
         
            +
                  generate 'rolify:role Role User mongoid'
         
     | 
| 
      
 919 
     | 
    
         
            +
                	# correct the generation of rolify 3.1 with mongoid
         
     | 
| 
      
 920 
     | 
    
         
            +
                	# the call to `rolify` should be *after* the inclusion of mongoid
         
     | 
| 
      
 921 
     | 
    
         
            +
                	# (see https://github.com/EppO/rolify/issues/61)
         
     | 
| 
      
 922 
     | 
    
         
            +
                	# This isn't needed for rolify>=3.2.0.beta4, but should cause no harm
         
     | 
| 
      
 923 
     | 
    
         
            +
                	gsub_file 'app/models/user.rb',
         
     | 
| 
      
 924 
     | 
    
         
            +
                		  /^\s*(rolify.*?)$\s*(include Mongoid::Document.*?)$/,
         
     | 
| 
      
 925 
     | 
    
         
            +
                		  "  \\2\n  extend Rolify\n  \\1\n"
         
     | 
| 
      
 926 
     | 
    
         
            +
                end
         
     | 
| 
      
 927 
     | 
    
         
            +
              end
         
     | 
| 
      
 928 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 929 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 930 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: models'" if prefer :git, true
         
     | 
| 
      
 931 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 932 
     | 
    
         
            +
             
     | 
| 
      
 933 
     | 
    
         
            +
             
     | 
| 
      
 934 
     | 
    
         
            +
            # >------------------------------[ controllers ]------------------------------<
         
     | 
| 
      
 935 
     | 
    
         
            +
             
     | 
| 
      
 936 
     | 
    
         
            +
            @current_recipe = "controllers"
         
     | 
| 
      
 937 
     | 
    
         
            +
            @before_configs["controllers"].call if @before_configs["controllers"]
         
     | 
| 
      
 938 
     | 
    
         
            +
            say_recipe 'controllers'
         
     | 
| 
      
 939 
     | 
    
         
            +
             
     | 
| 
      
 940 
     | 
    
         
            +
             
     | 
| 
      
 941 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 942 
     | 
    
         
            +
             
     | 
| 
      
 943 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 944 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/controllers.rb
         
     | 
| 
      
 945 
     | 
    
         
            +
             
     | 
| 
      
 946 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 947 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 948 
     | 
    
         
            +
              ### APPLICATION_CONTROLLER ###
         
     | 
| 
      
 949 
     | 
    
         
            +
              if prefer :authentication, 'omniauth'
         
     | 
| 
      
 950 
     | 
    
         
            +
                copy_from_repo 'app/controllers/application_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 951 
     | 
    
         
            +
              end
         
     | 
| 
      
 952 
     | 
    
         
            +
              if prefer :authorization, 'cancan'
         
     | 
| 
      
 953 
     | 
    
         
            +
                inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
         
     | 
| 
      
 954 
     | 
    
         
            +
              rescue_from CanCan::AccessDenied do |exception|
         
     | 
| 
      
 955 
     | 
    
         
            +
                redirect_to root_path, :alert => exception.message
         
     | 
| 
      
 956 
     | 
    
         
            +
              end
         
     | 
| 
      
 957 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 958 
     | 
    
         
            +
                end
         
     | 
| 
      
 959 
     | 
    
         
            +
              end  
         
     | 
| 
      
 960 
     | 
    
         
            +
              ### HOME_CONTROLLER ###
         
     | 
| 
      
 961 
     | 
    
         
            +
              if ['home_app','users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
         
     | 
| 
      
 962 
     | 
    
         
            +
                generate(:controller, "home index")
         
     | 
| 
      
 963 
     | 
    
         
            +
              end
         
     | 
| 
      
 964 
     | 
    
         
            +
              if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
         
     | 
| 
      
 965 
     | 
    
         
            +
                gsub_file 'app/controllers/home_controller.rb', /def index/, "def index\n    @users = User.all"
         
     | 
| 
      
 966 
     | 
    
         
            +
              end
         
     | 
| 
      
 967 
     | 
    
         
            +
              ### USERS_CONTROLLER ###
         
     | 
| 
      
 968 
     | 
    
         
            +
              if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
         
     | 
| 
      
 969 
     | 
    
         
            +
                if prefer :authentication, 'devise'
         
     | 
| 
      
 970 
     | 
    
         
            +
                  copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/'
         
     | 
| 
      
 971 
     | 
    
         
            +
                elsif prefer :authentication, 'omniauth'
         
     | 
| 
      
 972 
     | 
    
         
            +
                  copy_from_repo 'app/controllers/users_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 973 
     | 
    
         
            +
                end
         
     | 
| 
      
 974 
     | 
    
         
            +
                if prefer :authorization, 'cancan'
         
     | 
| 
      
 975 
     | 
    
         
            +
                  inject_into_file 'app/controllers/users_controller.rb', "    authorize! :index, @user, :message => 'Not authorized as an administrator.'\n", :after => "def index\n"
         
     | 
| 
      
 976 
     | 
    
         
            +
                end
         
     | 
| 
      
 977 
     | 
    
         
            +
              end
         
     | 
| 
      
 978 
     | 
    
         
            +
              gsub_file 'app/controllers/users_controller.rb', /before_filter :authenticate_user!/, '' if prefer :starter_app, 'subdomains'
         
     | 
| 
      
 979 
     | 
    
         
            +
              ### SESSIONS_CONTROLLER ###
         
     | 
| 
      
 980 
     | 
    
         
            +
              if prefer :authentication, 'omniauth'
         
     | 
| 
      
 981 
     | 
    
         
            +
                filename = 'app/controllers/sessions_controller.rb'
         
     | 
| 
      
 982 
     | 
    
         
            +
                copy_from_repo filename, :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/'
         
     | 
| 
      
 983 
     | 
    
         
            +
                gsub_file filename, /twitter/, prefs[:omniauth_provider] unless prefer :omniauth_provider, 'twitter'
         
     | 
| 
      
 984 
     | 
    
         
            +
              end
         
     | 
| 
      
 985 
     | 
    
         
            +
              ### PROFILES_CONTROLLER ###
         
     | 
| 
      
 986 
     | 
    
         
            +
              copy_from_repo 'app/controllers/profiles_controller.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains'
         
     | 
| 
      
 987 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 988 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 989 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: controllers'" if prefer :git, true
         
     | 
| 
      
 990 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 991 
     | 
    
         
            +
             
     | 
| 
      
 992 
     | 
    
         
            +
             
     | 
| 
      
 993 
     | 
    
         
            +
            # >---------------------------------[ views ]---------------------------------<
         
     | 
| 
      
 994 
     | 
    
         
            +
             
     | 
| 
      
 995 
     | 
    
         
            +
            @current_recipe = "views"
         
     | 
| 
      
 996 
     | 
    
         
            +
            @before_configs["views"].call if @before_configs["views"]
         
     | 
| 
      
 997 
     | 
    
         
            +
            say_recipe 'views'
         
     | 
| 
      
 998 
     | 
    
         
            +
             
     | 
| 
      
 999 
     | 
    
         
            +
             
     | 
| 
      
 1000 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1001 
     | 
    
         
            +
             
     | 
| 
      
 1002 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 1003 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/views.rb
         
     | 
| 
      
 1004 
     | 
    
         
            +
             
     | 
| 
      
 1005 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 1006 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 1007 
     | 
    
         
            +
              ### DEVISE ###
         
     | 
| 
      
 1008 
     | 
    
         
            +
              copy_from_repo 'app/views/devise/shared/_links.html.erb' if prefer :authentication, 'devise'
         
     | 
| 
      
 1009 
     | 
    
         
            +
              copy_from_repo 'app/views/devise/registrations/edit.html.erb' if prefer :authentication, 'devise'
         
     | 
| 
      
 1010 
     | 
    
         
            +
              copy_from_repo 'app/views/devise/registrations/new.html.erb' if prefer :authentication, 'devise'
         
     | 
| 
      
 1011 
     | 
    
         
            +
              ### HOME ###
         
     | 
| 
      
 1012 
     | 
    
         
            +
              copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'users_app'
         
     | 
| 
      
 1013 
     | 
    
         
            +
              copy_from_repo 'app/views/home/index.html.erb' if prefer :starter_app, 'admin_app'
         
     | 
| 
      
 1014 
     | 
    
         
            +
              copy_from_repo 'app/views/home/index-subdomains_app.html.erb', :prefs => 'subdomains_app'
         
     | 
| 
      
 1015 
     | 
    
         
            +
              ### USERS ###
         
     | 
| 
      
 1016 
     | 
    
         
            +
              if ['users_app','admin_app','subdomains_app'].include? prefs[:starter_app]
         
     | 
| 
      
 1017 
     | 
    
         
            +
                ## INDEX
         
     | 
| 
      
 1018 
     | 
    
         
            +
                copy_from_repo 'app/views/users/index.html.erb'
         
     | 
| 
      
 1019 
     | 
    
         
            +
                ## SHOW
         
     | 
| 
      
 1020 
     | 
    
         
            +
                copy_from_repo 'app/views/users/show.html.erb'
         
     | 
| 
      
 1021 
     | 
    
         
            +
                copy_from_repo 'app/views/users/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
         
     | 
| 
      
 1022 
     | 
    
         
            +
                ## EDIT
         
     | 
| 
      
 1023 
     | 
    
         
            +
                copy_from_repo 'app/views/users/edit-omniauth.html.erb', :prefs => 'omniauth'
         
     | 
| 
      
 1024 
     | 
    
         
            +
              end
         
     | 
| 
      
 1025 
     | 
    
         
            +
              ### PROFILES ###
         
     | 
| 
      
 1026 
     | 
    
         
            +
              copy_from_repo 'app/views/profiles/show-subdomains_app.html.erb', :prefs => 'subdomains_app'
         
     | 
| 
      
 1027 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 1028 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 1029 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: views'" if prefer :git, true
         
     | 
| 
      
 1030 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 1031 
     | 
    
         
            +
             
     | 
| 
      
 1032 
     | 
    
         
            +
             
     | 
| 
      
 1033 
     | 
    
         
            +
            # >------------------------------[ haml_views ]-------------------------------<
         
     | 
| 
      
 1034 
     | 
    
         
            +
             
     | 
| 
      
 1035 
     | 
    
         
            +
            @current_recipe = "haml_views"
         
     | 
| 
      
 1036 
     | 
    
         
            +
            @before_configs["haml_views"].call if @before_configs["haml_views"]
         
     | 
| 
      
 1037 
     | 
    
         
            +
            say_recipe 'haml_views'
         
     | 
| 
      
 1038 
     | 
    
         
            +
             
     | 
| 
      
 1039 
     | 
    
         
            +
             
     | 
| 
      
 1040 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1041 
     | 
    
         
            +
             
     | 
| 
      
 1042 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 1043 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 1044 
     | 
    
         
            +
             
     | 
| 
      
 1045 
     | 
    
         
            +
              # Convert all views to Haml
         
     | 
| 
      
 1046 
     | 
    
         
            +
              run "for i in `find app/views -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; done"
         
     | 
| 
      
 1047 
     | 
    
         
            +
             
     | 
| 
      
 1048 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 1049 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 1050 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: Haml starter views.'" if prefer :git, true
         
     | 
| 
      
 1051 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 1052 
     | 
    
         
            +
             
     | 
| 
      
 1053 
     | 
    
         
            +
             
     | 
| 
      
 1054 
     | 
    
         
            +
            # >--------------------------------[ routes ]---------------------------------<
         
     | 
| 
      
 1055 
     | 
    
         
            +
             
     | 
| 
      
 1056 
     | 
    
         
            +
            @current_recipe = "routes"
         
     | 
| 
      
 1057 
     | 
    
         
            +
            @before_configs["routes"].call if @before_configs["routes"]
         
     | 
| 
      
 1058 
     | 
    
         
            +
            say_recipe 'routes'
         
     | 
| 
      
 1059 
     | 
    
         
            +
             
     | 
| 
      
 1060 
     | 
    
         
            +
             
     | 
| 
      
 1061 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1062 
     | 
    
         
            +
             
     | 
| 
      
 1063 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 1064 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/routes.rb
         
     | 
| 
      
 1065 
     | 
    
         
            +
             
     | 
| 
      
 1066 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 1067 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 1068 
     | 
    
         
            +
              ### HOME ###
         
     | 
| 
      
 1069 
     | 
    
         
            +
              if prefer :starter_app, 'home_app'
         
     | 
| 
      
 1070 
     | 
    
         
            +
                remove_file 'public/index.html'
         
     | 
| 
      
 1071 
     | 
    
         
            +
                gsub_file 'config/routes.rb', /get \"home\/index\"/, 'root :to => "home#index"'
         
     | 
| 
      
 1072 
     | 
    
         
            +
              end
         
     | 
| 
      
 1073 
     | 
    
         
            +
              ### USER_ACCOUNTS ###
         
     | 
| 
      
 1074 
     | 
    
         
            +
              if ['users_app','admin_app'].include? prefs[:starter_app]
         
     | 
| 
      
 1075 
     | 
    
         
            +
                ## DEVISE
         
     | 
| 
      
 1076 
     | 
    
         
            +
                copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-devise-rspec-cucumber/master/' if prefer :authentication, 'devise'
         
     | 
| 
      
 1077 
     | 
    
         
            +
                ## OMNIAUTH
         
     | 
| 
      
 1078 
     | 
    
         
            +
                copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-mongoid-omniauth/master/' if prefer :authentication, 'omniauth'
         
     | 
| 
      
 1079 
     | 
    
         
            +
              end
         
     | 
| 
      
 1080 
     | 
    
         
            +
              ### SUBDOMAINS ###
         
     | 
| 
      
 1081 
     | 
    
         
            +
              copy_from_repo 'lib/subdomain.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains'
         
     | 
| 
      
 1082 
     | 
    
         
            +
              copy_from_repo 'config/routes.rb', :repo => 'https://raw.github.com/RailsApps/rails3-subdomains/master/' if prefer :starter_app, 'subdomains'
         
     | 
| 
      
 1083 
     | 
    
         
            +
              ### CORRECT APPLICATION NAME ###
         
     | 
| 
      
 1084 
     | 
    
         
            +
              gsub_file 'config/routes.rb', /^.*.routes.draw do/, "#{app_const}.routes.draw do"
         
     | 
| 
      
 1085 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 1086 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 1087 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: routes'" if prefer :git, true
         
     | 
| 
      
 1088 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 1089 
     | 
    
         
            +
             
     | 
| 
      
 1090 
     | 
    
         
            +
             
     | 
| 
      
 1091 
     | 
    
         
            +
            # >-------------------------------[ frontend ]--------------------------------<
         
     | 
| 
      
 1092 
     | 
    
         
            +
             
     | 
| 
      
 1093 
     | 
    
         
            +
            @current_recipe = "frontend"
         
     | 
| 
      
 1094 
     | 
    
         
            +
            @before_configs["frontend"].call if @before_configs["frontend"]
         
     | 
| 
      
 1095 
     | 
    
         
            +
            say_recipe 'frontend'
         
     | 
| 
      
 1096 
     | 
    
         
            +
             
     | 
| 
      
 1097 
     | 
    
         
            +
             
     | 
| 
      
 1098 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1099 
     | 
    
         
            +
             
     | 
| 
      
 1100 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 1101 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/frontend.rb
         
     | 
| 
      
 1102 
     | 
    
         
            +
             
     | 
| 
      
 1103 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 1104 
     | 
    
         
            +
              say_wizard "recipe running after 'bundle install'"
         
     | 
| 
      
 1105 
     | 
    
         
            +
              ### LAYOUTS ###
         
     | 
| 
      
 1106 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/application.html.erb'
         
     | 
| 
      
 1107 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/application-bootstrap.html.erb', :prefs => 'bootstrap'
         
     | 
| 
      
 1108 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_messages.html.erb'
         
     | 
| 
      
 1109 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_messages-bootstrap.html.erb', :prefs => 'bootstrap'
         
     | 
| 
      
 1110 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_navigation.html.erb'
         
     | 
| 
      
 1111 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_navigation-devise.html.erb', :prefs => 'devise'
         
     | 
| 
      
 1112 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_navigation-cancan.html.erb', :prefs => 'cancan'
         
     | 
| 
      
 1113 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_navigation-omniauth.html.erb', :prefs => 'omniauth'
         
     | 
| 
      
 1114 
     | 
    
         
            +
              copy_from_repo 'app/views/layouts/_navigation-subdomains_app.html.erb', :prefs => 'subdomains_app'  
         
     | 
| 
      
 1115 
     | 
    
         
            +
              ## APPLICATION NAME
         
     | 
| 
      
 1116 
     | 
    
         
            +
              application_layout_file = Dir['app/views/layouts/application.html.*'].first
         
     | 
| 
      
 1117 
     | 
    
         
            +
              navigation_partial_file = Dir['app/views/layouts/_navigation.html.*'].first
         
     | 
| 
      
 1118 
     | 
    
         
            +
              gsub_file application_layout_file, /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1119 
     | 
    
         
            +
              gsub_file navigation_partial_file, /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1120 
     | 
    
         
            +
              ### CSS ###
         
     | 
| 
      
 1121 
     | 
    
         
            +
              remove_file 'app/assets/stylesheets/application.css'
         
     | 
| 
      
 1122 
     | 
    
         
            +
              copy_from_repo 'app/assets/stylesheets/application.css.scss'
         
     | 
| 
      
 1123 
     | 
    
         
            +
              copy_from_repo 'app/assets/stylesheets/application-bootstrap.css.scss', :prefs => 'bootstrap'
         
     | 
| 
      
 1124 
     | 
    
         
            +
              if prefer :bootstrap, 'less'
         
     | 
| 
      
 1125 
     | 
    
         
            +
                generate 'bootstrap:install'
         
     | 
| 
      
 1126 
     | 
    
         
            +
                insert_into_file 'app/assets/stylesheets/bootstrap_and_overrides.css.less', "body { padding-top: 60px; }\n", :after => "@import \"twitter/bootstrap/bootstrap\";\n"
         
     | 
| 
      
 1127 
     | 
    
         
            +
              elsif prefer :bootstrap, 'sass'
         
     | 
| 
      
 1128 
     | 
    
         
            +
                insert_into_file 'app/assets/javascripts/application.js', "//= require bootstrap\n", :after => "jquery_ujs\n"
         
     | 
| 
      
 1129 
     | 
    
         
            +
                create_file 'app/assets/stylesheets/bootstrap_and_overrides.css.scss', <<-RUBY
         
     | 
| 
      
 1130 
     | 
    
         
            +
            @import "bootstrap";
         
     | 
| 
      
 1131 
     | 
    
         
            +
            body { padding-top: 60px; }
         
     | 
| 
      
 1132 
     | 
    
         
            +
            @import "bootstrap-responsive";
         
     | 
| 
      
 1133 
     | 
    
         
            +
            RUBY
         
     | 
| 
      
 1134 
     | 
    
         
            +
              elsif prefer :frontend, 'foundation'
         
     | 
| 
      
 1135 
     | 
    
         
            +
                insert_into_file 'app/assets/javascripts/application.js', "//= require foundation\n", :after => "jquery_ujs\n"
         
     | 
| 
      
 1136 
     | 
    
         
            +
                insert_into_file 'app/assets/stylesheets/application.css.scss', " *= require foundation\n", :after => "require_self\n"
         
     | 
| 
      
 1137 
     | 
    
         
            +
              elsif prefer :frontend, 'skeleton'
         
     | 
| 
      
 1138 
     | 
    
         
            +
                copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
         
     | 
| 
      
 1139 
     | 
    
         
            +
                copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/base.css', 'app/assets/stylesheets/base.css'
         
     | 
| 
      
 1140 
     | 
    
         
            +
                copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/layout.css', 'app/assets/stylesheets/layout.css'
         
     | 
| 
      
 1141 
     | 
    
         
            +
                copy_from 'https://raw.github.com/dhgamache/Skeleton/master/stylesheets/skeleton.css', 'app/assets/stylesheets/skeleton.css'
         
     | 
| 
      
 1142 
     | 
    
         
            +
              elsif prefer :frontend, 'normalize'
         
     | 
| 
      
 1143 
     | 
    
         
            +
                copy_from 'https://raw.github.com/necolas/normalize.css/master/normalize.css', 'app/assets/stylesheets/normalize.css'
         
     | 
| 
      
 1144 
     | 
    
         
            +
              end
         
     | 
| 
      
 1145 
     | 
    
         
            +
              ### GIT ###
         
     | 
| 
      
 1146 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 1147 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: front-end framework'" if prefer :git, true
         
     | 
| 
      
 1148 
     | 
    
         
            +
            end # after_bundler
         
     | 
| 
      
 1149 
     | 
    
         
            +
             
     | 
| 
      
 1150 
     | 
    
         
            +
             
     | 
| 
      
 1151 
     | 
    
         
            +
            # >---------------------------------[ html5 ]---------------------------------<
         
     | 
| 
      
 1152 
     | 
    
         
            +
             
     | 
| 
      
 1153 
     | 
    
         
            +
            @current_recipe = "html5"
         
     | 
| 
      
 1154 
     | 
    
         
            +
            @before_configs["html5"].call if @before_configs["html5"]
         
     | 
| 
      
 1155 
     | 
    
         
            +
            say_recipe 'html5'
         
     | 
| 
      
 1156 
     | 
    
         
            +
             
     | 
| 
      
 1157 
     | 
    
         
            +
             
     | 
| 
      
 1158 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1159 
     | 
    
         
            +
             
     | 
| 
      
 1160 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Check for a newer version here:
         
     | 
| 
      
 1161 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/html5.rb
         
     | 
| 
      
 1162 
     | 
    
         
            +
             
     | 
| 
      
 1163 
     | 
    
         
            +
            after_bundler do
         
     | 
| 
      
 1164 
     | 
    
         
            +
              say_wizard "HTML5 recipe running 'after bundler'"
         
     | 
| 
      
 1165 
     | 
    
         
            +
              # add a humans.txt file
         
     | 
| 
      
 1166 
     | 
    
         
            +
              get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/humans.txt', 'public/humans.txt'
         
     | 
| 
      
 1167 
     | 
    
         
            +
              # install a front-end framework for HTML5 and CSS3
         
     | 
| 
      
 1168 
     | 
    
         
            +
              remove_file 'app/assets/stylesheets/application.css'
         
     | 
| 
      
 1169 
     | 
    
         
            +
              remove_file 'app/views/layouts/application.html.erb'
         
     | 
| 
      
 1170 
     | 
    
         
            +
              remove_file 'app/views/layouts/application.html.haml'
         
     | 
| 
      
 1171 
     | 
    
         
            +
              unless recipes.include? 'bootstrap'
         
     | 
| 
      
 1172 
     | 
    
         
            +
                if recipes.include? 'haml'
         
     | 
| 
      
 1173 
     | 
    
         
            +
                  # Haml version of a simple application layout
         
     | 
| 
      
 1174 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
         
     | 
| 
      
 1175 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
         
     | 
| 
      
 1176 
     | 
    
         
            +
                else
         
     | 
| 
      
 1177 
     | 
    
         
            +
                  # ERB version of a simple application layout
         
     | 
| 
      
 1178 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
         
     | 
| 
      
 1179 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb'
         
     | 
| 
      
 1180 
     | 
    
         
            +
                end
         
     | 
| 
      
 1181 
     | 
    
         
            +
                # simple css styles
         
     | 
| 
      
 1182 
     | 
    
         
            +
                get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/simple/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'  
         
     | 
| 
      
 1183 
     | 
    
         
            +
              else # for Twitter Bootstrap
         
     | 
| 
      
 1184 
     | 
    
         
            +
                if recipes.include? 'haml'
         
     | 
| 
      
 1185 
     | 
    
         
            +
                  # Haml version of a complex application layout using Twitter Bootstrap
         
     | 
| 
      
 1186 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.haml', 'app/views/layouts/application.html.haml'
         
     | 
| 
      
 1187 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.haml', 'app/views/layouts/_messages.html.haml'
         
     | 
| 
      
 1188 
     | 
    
         
            +
                else
         
     | 
| 
      
 1189 
     | 
    
         
            +
                  # ERB version of a complex application layout using Twitter Bootstrap
         
     | 
| 
      
 1190 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
         
     | 
| 
      
 1191 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/views/layouts/_messages.html.erb', 'app/views/layouts/_messages.html.erb'
         
     | 
| 
      
 1192 
     | 
    
         
            +
                end
         
     | 
| 
      
 1193 
     | 
    
         
            +
                # complex css styles using Twitter Bootstrap
         
     | 
| 
      
 1194 
     | 
    
         
            +
                get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/twitter-bootstrap/assets/stylesheets/application.css.scss', 'app/assets/stylesheets/application.css.scss'
         
     | 
| 
      
 1195 
     | 
    
         
            +
              end
         
     | 
| 
      
 1196 
     | 
    
         
            +
              # get an appropriate navigation partial
         
     | 
| 
      
 1197 
     | 
    
         
            +
              if recipes.include? 'haml'
         
     | 
| 
      
 1198 
     | 
    
         
            +
                if recipes.include? 'devise'
         
     | 
| 
      
 1199 
     | 
    
         
            +
                  if recipes.include? 'authorization'
         
     | 
| 
      
 1200 
     | 
    
         
            +
                    get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
         
     | 
| 
      
 1201 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1202 
     | 
    
         
            +
                    get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'        
         
     | 
| 
      
 1203 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1204 
     | 
    
         
            +
                elsif recipes.include? 'omniauth'
         
     | 
| 
      
 1205 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
         
     | 
| 
      
 1206 
     | 
    
         
            +
                elsif recipes.include? 'subdomains'
         
     | 
| 
      
 1207 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
         
     | 
| 
      
 1208 
     | 
    
         
            +
                else
         
     | 
| 
      
 1209 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.haml', 'app/views/layouts/_navigation.html.haml'
         
     | 
| 
      
 1210 
     | 
    
         
            +
                end
         
     | 
| 
      
 1211 
     | 
    
         
            +
              else
         
     | 
| 
      
 1212 
     | 
    
         
            +
                if recipes.include? 'devise'
         
     | 
| 
      
 1213 
     | 
    
         
            +
                  if recipes.include? 'authorization'
         
     | 
| 
      
 1214 
     | 
    
         
            +
                    get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/authorization/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
         
     | 
| 
      
 1215 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1216 
     | 
    
         
            +
                    get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/devise/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'        
         
     | 
| 
      
 1217 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1218 
     | 
    
         
            +
                elsif recipes.include? 'omniauth'
         
     | 
| 
      
 1219 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/omniauth/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
         
     | 
| 
      
 1220 
     | 
    
         
            +
                elsif recipes.include? 'subdomains'
         
     | 
| 
      
 1221 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/subdomains/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
         
     | 
| 
      
 1222 
     | 
    
         
            +
                else
         
     | 
| 
      
 1223 
     | 
    
         
            +
                  get 'https://raw.github.com/RailsApps/rails3-application-templates/master/files/navigation/none/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
         
     | 
| 
      
 1224 
     | 
    
         
            +
                end
         
     | 
| 
      
 1225 
     | 
    
         
            +
              end
         
     | 
| 
      
 1226 
     | 
    
         
            +
              if recipes.include? 'haml'
         
     | 
| 
      
 1227 
     | 
    
         
            +
                gsub_file 'app/views/layouts/application.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1228 
     | 
    
         
            +
                gsub_file 'app/views/layouts/_navigation.html.haml', /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1229 
     | 
    
         
            +
              else
         
     | 
| 
      
 1230 
     | 
    
         
            +
                gsub_file 'app/views/layouts/application.html.erb', /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1231 
     | 
    
         
            +
                gsub_file 'app/views/layouts/_navigation.html.erb', /App_Name/, "#{app_name.humanize.titleize}"
         
     | 
| 
      
 1232 
     | 
    
         
            +
              end
         
     | 
| 
      
 1233 
     | 
    
         
            +
            end
         
     | 
| 
      
 1234 
     | 
    
         
            +
             
     | 
| 
      
 1235 
     | 
    
         
            +
             
     | 
| 
      
 1236 
     | 
    
         
            +
            # >--------------------------------[ extras ]---------------------------------<
         
     | 
| 
      
 1237 
     | 
    
         
            +
             
     | 
| 
      
 1238 
     | 
    
         
            +
            @current_recipe = "extras"
         
     | 
| 
      
 1239 
     | 
    
         
            +
            @before_configs["extras"].call if @before_configs["extras"]
         
     | 
| 
      
 1240 
     | 
    
         
            +
            say_recipe 'extras'
         
     | 
| 
      
 1241 
     | 
    
         
            +
             
     | 
| 
      
 1242 
     | 
    
         
            +
            config = {}
         
     | 
| 
      
 1243 
     | 
    
         
            +
            config['form_builder'] = multiple_choice("Use a form builder gem?", [["None", "none"], ["SimpleForm", "simple_form"]]) if true && true unless config.key?('form_builder') || prefs.has_key?(:form_builder)
         
     | 
| 
      
 1244 
     | 
    
         
            +
            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)
         
     | 
| 
      
 1245 
     | 
    
         
            +
            config['jsruntime'] = yes_wizard?("Add 'therubyracer' JavaScript runtime (for Linux users without node.js)?") if true && true unless config.key?('jsruntime') || prefs.has_key?(:jsruntime)
         
     | 
| 
      
 1246 
     | 
    
         
            +
            config['rvmrc'] = yes_wizard?("Create a project-specific rvm gemset and .rvmrc?") if true && true unless config.key?('rvmrc') || prefs.has_key?(:rvmrc)
         
     | 
| 
      
 1247 
     | 
    
         
            +
            @configs[@current_recipe] = config
         
     | 
| 
      
 1248 
     | 
    
         
            +
             
     | 
| 
      
 1249 
     | 
    
         
            +
            # Application template recipe for the rails_apps_composer. Change the recipe here:
         
     | 
| 
      
 1250 
     | 
    
         
            +
            # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/extras.rb
         
     | 
| 
      
 1251 
     | 
    
         
            +
             
     | 
| 
      
 1252 
     | 
    
         
            +
            ## FORM BUILDER
         
     | 
| 
      
 1253 
     | 
    
         
            +
            case config['form_builder']
         
     | 
| 
      
 1254 
     | 
    
         
            +
              when 'simple_form'
         
     | 
| 
      
 1255 
     | 
    
         
            +
                prefs[:form_builder] = 'simple_form'
         
     | 
| 
      
 1256 
     | 
    
         
            +
            end
         
     | 
| 
      
 1257 
     | 
    
         
            +
            case prefs[:form_builder]
         
     | 
| 
      
 1258 
     | 
    
         
            +
              when 'simple_form'
         
     | 
| 
      
 1259 
     | 
    
         
            +
                gem 'simple_form'
         
     | 
| 
      
 1260 
     | 
    
         
            +
                after_bundler do
         
     | 
| 
      
 1261 
     | 
    
         
            +
                  if prefer :frontend, 'bootstrap'
         
     | 
| 
      
 1262 
     | 
    
         
            +
                    say_wizard "recipe installing simple_form for use with Twitter Bootstrap"
         
     | 
| 
      
 1263 
     | 
    
         
            +
                    generate 'simple_form:install --bootstrap'
         
     | 
| 
      
 1264 
     | 
    
         
            +
                  else
         
     | 
| 
      
 1265 
     | 
    
         
            +
                    say_wizard "recipe installing simple_form"
         
     | 
| 
      
 1266 
     | 
    
         
            +
                    generate 'simple_form:install'
         
     | 
| 
      
 1267 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1268 
     | 
    
         
            +
                end
         
     | 
| 
      
 1269 
     | 
    
         
            +
            end
         
     | 
| 
      
 1270 
     | 
    
         
            +
             
     | 
| 
      
 1271 
     | 
    
         
            +
            ## BAN SPIDERS
         
     | 
| 
      
 1272 
     | 
    
         
            +
            if config['ban_spiders']
         
     | 
| 
      
 1273 
     | 
    
         
            +
              prefs[:ban_spiders] = true
         
     | 
| 
      
 1274 
     | 
    
         
            +
            end
         
     | 
| 
      
 1275 
     | 
    
         
            +
            if prefs[:ban_spiders]
         
     | 
| 
      
 1276 
     | 
    
         
            +
              say_wizard "Banning spiders by modifying 'public/robots.txt'"
         
     | 
| 
      
 1277 
     | 
    
         
            +
              after_bundler do
         
     | 
| 
      
 1278 
     | 
    
         
            +
                gsub_file 'public/robots.txt', /# User-Agent/, 'User-Agent'
         
     | 
| 
      
 1279 
     | 
    
         
            +
                gsub_file 'public/robots.txt', /# Disallow/, 'Disallow'
         
     | 
| 
      
 1280 
     | 
    
         
            +
              end
         
     | 
| 
      
 1281 
     | 
    
         
            +
            end
         
     | 
| 
      
 1282 
     | 
    
         
            +
             
     | 
| 
      
 1283 
     | 
    
         
            +
            ## JSRUNTIME
         
     | 
| 
      
 1284 
     | 
    
         
            +
            if config['jsruntime']
         
     | 
| 
      
 1285 
     | 
    
         
            +
              prefs[:jsruntime] = true
         
     | 
| 
      
 1286 
     | 
    
         
            +
            end
         
     | 
| 
      
 1287 
     | 
    
         
            +
            if prefs[:jsruntime]
         
     | 
| 
      
 1288 
     | 
    
         
            +
              say_wizard "Adding 'therubyracer' JavaScript runtime gem"
         
     | 
| 
      
 1289 
     | 
    
         
            +
              # maybe it was already added for bootstrap-less?
         
     | 
| 
      
 1290 
     | 
    
         
            +
              unless prefer :bootstrap, 'less'
         
     | 
| 
      
 1291 
     | 
    
         
            +
                gem 'therubyracer', :group => :assets, :platform => :ruby
         
     | 
| 
      
 1292 
     | 
    
         
            +
              end
         
     | 
| 
      
 1293 
     | 
    
         
            +
            end
         
     | 
| 
      
 1294 
     | 
    
         
            +
             
     | 
| 
      
 1295 
     | 
    
         
            +
            ## RVMRC
         
     | 
| 
      
 1296 
     | 
    
         
            +
            if config['rvmrc']
         
     | 
| 
      
 1297 
     | 
    
         
            +
              prefs[:rvmrc] = true
         
     | 
| 
      
 1298 
     | 
    
         
            +
            end
         
     | 
| 
      
 1299 
     | 
    
         
            +
            if prefs[:rvmrc]
         
     | 
| 
      
 1300 
     | 
    
         
            +
              # using the rvm Ruby API, see:
         
     | 
| 
      
 1301 
     | 
    
         
            +
              # http://blog.thefrontiergroup.com.au/2010/12/a-brief-introduction-to-the-rvm-ruby-api/
         
     | 
| 
      
 1302 
     | 
    
         
            +
              if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
         
     | 
| 
      
 1303 
     | 
    
         
            +
                begin
         
     | 
| 
      
 1304 
     | 
    
         
            +
                  rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
         
     | 
| 
      
 1305 
     | 
    
         
            +
                  rvm_lib_path = File.join(rvm_path, 'lib')
         
     | 
| 
      
 1306 
     | 
    
         
            +
                  require 'rvm'
         
     | 
| 
      
 1307 
     | 
    
         
            +
                rescue LoadError
         
     | 
| 
      
 1308 
     | 
    
         
            +
                  raise "RVM ruby lib is currently unavailable."
         
     | 
| 
      
 1309 
     | 
    
         
            +
                end
         
     | 
| 
      
 1310 
     | 
    
         
            +
              else
         
     | 
| 
      
 1311 
     | 
    
         
            +
                raise "RVM ruby lib is currently unavailable."
         
     | 
| 
      
 1312 
     | 
    
         
            +
              end
         
     | 
| 
      
 1313 
     | 
    
         
            +
              say_wizard "creating RVM gemset '#{app_name}'"
         
     | 
| 
      
 1314 
     | 
    
         
            +
              RVM.gemset_create app_name
         
     | 
| 
      
 1315 
     | 
    
         
            +
              run "rvm rvmrc trust"
         
     | 
| 
      
 1316 
     | 
    
         
            +
              say_wizard "switching to gemset '#{app_name}'"
         
     | 
| 
      
 1317 
     | 
    
         
            +
              begin
         
     | 
| 
      
 1318 
     | 
    
         
            +
                RVM.gemset_use! app_name
         
     | 
| 
      
 1319 
     | 
    
         
            +
              rescue StandardError
         
     | 
| 
      
 1320 
     | 
    
         
            +
                raise "rvm failure: unable to use gemset #{app_name}"
         
     | 
| 
      
 1321 
     | 
    
         
            +
              end
         
     | 
| 
      
 1322 
     | 
    
         
            +
              run "rvm gemset list"
         
     | 
| 
      
 1323 
     | 
    
         
            +
              copy_from_repo '.rvmrc'
         
     | 
| 
      
 1324 
     | 
    
         
            +
              gsub_file '.rvmrc', /App_Name/, "#{app_name}"
         
     | 
| 
      
 1325 
     | 
    
         
            +
            end
         
     | 
| 
      
 1326 
     | 
    
         
            +
             
     | 
| 
      
 1327 
     | 
    
         
            +
            ## AFTER_EVERYTHING
         
     | 
| 
      
 1328 
     | 
    
         
            +
            after_everything do
         
     | 
| 
      
 1329 
     | 
    
         
            +
              say_wizard "recipe removing unnecessary files and whitespace"
         
     | 
| 
      
 1330 
     | 
    
         
            +
              %w{
         
     | 
| 
      
 1331 
     | 
    
         
            +
                public/index.html
         
     | 
| 
      
 1332 
     | 
    
         
            +
                app/assets/images/rails.png
         
     | 
| 
      
 1333 
     | 
    
         
            +
              }.each { |file| remove_file file }
         
     | 
| 
      
 1334 
     | 
    
         
            +
              # remove commented lines and multiple blank lines from Gemfile
         
     | 
| 
      
 1335 
     | 
    
         
            +
              # thanks to https://github.com/perfectline/template-bucket/blob/master/cleanup.rb
         
     | 
| 
      
 1336 
     | 
    
         
            +
              gsub_file 'Gemfile', /#.*\n/, "\n"
         
     | 
| 
      
 1337 
     | 
    
         
            +
              gsub_file 'Gemfile', /\n^\s*\n/, "\n"
         
     | 
| 
      
 1338 
     | 
    
         
            +
              # remove commented lines and multiple blank lines from config/routes.rb
         
     | 
| 
      
 1339 
     | 
    
         
            +
              gsub_file 'config/routes.rb', /  #.*\n/, "\n"
         
     | 
| 
      
 1340 
     | 
    
         
            +
              gsub_file 'config/routes.rb', /\n^\s*\n/, "\n"
         
     | 
| 
      
 1341 
     | 
    
         
            +
              # GIT
         
     | 
| 
      
 1342 
     | 
    
         
            +
              git :add => '.' if prefer :git, true
         
     | 
| 
      
 1343 
     | 
    
         
            +
              git :commit => "-aqm 'rails_apps_composer: extras'" if prefer :git, true
         
     | 
| 
      
 1344 
     | 
    
         
            +
            end
         
     | 
| 
      
 1345 
     | 
    
         
            +
             
     | 
| 
      
 1346 
     | 
    
         
            +
             
     | 
| 
      
 1347 
     | 
    
         
            +
             
     | 
| 
      
 1348 
     | 
    
         
            +
            # >---------------------------------[ Diagnostics ]----------------------------------<
         
     | 
| 
      
 1349 
     | 
    
         
            +
             
     | 
| 
      
 1350 
     | 
    
         
            +
            # remove prefs which are diagnostically irrelevant
         
     | 
| 
      
 1351 
     | 
    
         
            +
            redacted_prefs = prefs
         
     | 
| 
      
 1352 
     | 
    
         
            +
            redacted_prefs.delete(:git)
         
     | 
| 
      
 1353 
     | 
    
         
            +
            redacted_prefs.delete(:dev_webserver)
         
     | 
| 
      
 1354 
     | 
    
         
            +
            redacted_prefs.delete(:prod_webserver)
         
     | 
| 
      
 1355 
     | 
    
         
            +
            redacted_prefs.delete(:ban_spiders)
         
     | 
| 
      
 1356 
     | 
    
         
            +
            redacted_prefs.delete(:jsruntime)
         
     | 
| 
      
 1357 
     | 
    
         
            +
            redacted_prefs.delete(:rvmrc)
         
     | 
| 
      
 1358 
     | 
    
         
            +
             
     | 
| 
      
 1359 
     | 
    
         
            +
            if diagnostics_prefs.include? redacted_prefs
         
     | 
| 
      
 1360 
     | 
    
         
            +
              diagnostics[:prefs] = 'success'
         
     | 
| 
      
 1361 
     | 
    
         
            +
            else
         
     | 
| 
      
 1362 
     | 
    
         
            +
              diagnostics[:prefs] = 'fail'
         
     | 
| 
      
 1363 
     | 
    
         
            +
            end
         
     | 
| 
      
 1364 
     | 
    
         
            +
             
     | 
| 
      
 1365 
     | 
    
         
            +
             
     | 
| 
      
 1366 
     | 
    
         
            +
             
     | 
| 
      
 1367 
     | 
    
         
            +
            @current_recipe = nil
         
     | 
| 
      
 1368 
     | 
    
         
            +
             
     | 
| 
      
 1369 
     | 
    
         
            +
            # >-----------------------------[ Run 'Bundle Install' ]-------------------------------<
         
     | 
| 
      
 1370 
     | 
    
         
            +
             
     | 
| 
      
 1371 
     | 
    
         
            +
            say_wizard "Installing gems. This will take a while."
         
     | 
| 
      
 1372 
     | 
    
         
            +
            if prefs.has_key? :bundle_path
         
     | 
| 
      
 1373 
     | 
    
         
            +
              run "bundle install --without production --path #{prefs[:bundle_path]}"
         
     | 
| 
      
 1374 
     | 
    
         
            +
            else
         
     | 
| 
      
 1375 
     | 
    
         
            +
              run 'bundle install --without production'
         
     | 
| 
      
 1376 
     | 
    
         
            +
            end
         
     | 
| 
      
 1377 
     | 
    
         
            +
             
     | 
| 
      
 1378 
     | 
    
         
            +
            # >-----------------------------[ Run 'After Bundler' Callbacks ]-------------------------------<
         
     | 
| 
      
 1379 
     | 
    
         
            +
             
     | 
| 
      
 1380 
     | 
    
         
            +
            say_wizard "Running 'after bundler' callbacks."
         
     | 
| 
      
 1381 
     | 
    
         
            +
            require 'bundler/setup'
         
     | 
| 
      
 1382 
     | 
    
         
            +
            if prefer :templates, 'haml'
         
     | 
| 
      
 1383 
     | 
    
         
            +
              say_wizard "importing html2haml conversion tool"
         
     | 
| 
      
 1384 
     | 
    
         
            +
              require 'haml/html'
         
     | 
| 
      
 1385 
     | 
    
         
            +
            end
         
     | 
| 
      
 1386 
     | 
    
         
            +
            if prefer :templates, 'slim'
         
     | 
| 
      
 1387 
     | 
    
         
            +
              say_wizard "importing html2haml and haml2slim conversion tools"
         
     | 
| 
      
 1388 
     | 
    
         
            +
              require 'haml/html'
         
     | 
| 
      
 1389 
     | 
    
         
            +
              require 'haml2slim'
         
     | 
| 
      
 1390 
     | 
    
         
            +
            end
         
     | 
| 
      
 1391 
     | 
    
         
            +
            @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
         
     | 
| 
      
 1392 
     | 
    
         
            +
             
     | 
| 
      
 1393 
     | 
    
         
            +
            # >-----------------------------[ Run 'After Everything' Callbacks ]-------------------------------<
         
     | 
| 
      
 1394 
     | 
    
         
            +
             
     | 
| 
      
 1395 
     | 
    
         
            +
            @current_recipe = nil
         
     | 
| 
      
 1396 
     | 
    
         
            +
            say_wizard "Running 'after everything' callbacks."
         
     | 
| 
      
 1397 
     | 
    
         
            +
            @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
         
     | 
| 
      
 1398 
     | 
    
         
            +
             
     | 
| 
      
 1399 
     | 
    
         
            +
            @current_recipe = nil
         
     | 
| 
      
 1400 
     | 
    
         
            +
            if diagnostics[:recipes] == 'success'
         
     | 
| 
      
 1401 
     | 
    
         
            +
              say_wizard("WOOT! The recipes you've selected are known to work together.")
         
     | 
| 
      
 1402 
     | 
    
         
            +
              say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.")
         
     | 
| 
      
 1403 
     | 
    
         
            +
            else
         
     | 
| 
      
 1404 
     | 
    
         
            +
              say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m")
         
     | 
| 
      
 1405 
     | 
    
         
            +
              say_wizard("Help us out by reporting whether this combination works or fails.")
         
     | 
| 
      
 1406 
     | 
    
         
            +
              say_wizard("Please open an issue for rails_apps_composer on GitHub.")
         
     | 
| 
      
 1407 
     | 
    
         
            +
              say_wizard("Your new application will contain diagnostics in its README file.")
         
     | 
| 
      
 1408 
     | 
    
         
            +
            end
         
     | 
| 
      
 1409 
     | 
    
         
            +
            if diagnostics[:prefs] == 'success'
         
     | 
| 
      
 1410 
     | 
    
         
            +
              say_wizard("WOOT! The preferences you've selected are known to work together.")
         
     | 
| 
      
 1411 
     | 
    
         
            +
              say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.")
         
     | 
| 
      
 1412 
     | 
    
         
            +
            else
         
     | 
| 
      
 1413 
     | 
    
         
            +
              say_wizard("\033[1m\033[36m" + "WARNING! The preferences you've selected might not work together." + "\033[0m")
         
     | 
| 
      
 1414 
     | 
    
         
            +
              say_wizard("Help us out by reporting whether this combination works or fails.")
         
     | 
| 
      
 1415 
     | 
    
         
            +
              say_wizard("Please open an issue for rails_apps_composer on GitHub.")
         
     | 
| 
      
 1416 
     | 
    
         
            +
              say_wizard("Your new application will contain diagnostics in its README file.")
         
     | 
| 
      
 1417 
     | 
    
         
            +
            end
         
     | 
| 
      
 1418 
     | 
    
         
            +
            say_wizard "Finished running the rails_apps_composer app template."
         
     | 
| 
      
 1419 
     | 
    
         
            +
            say_wizard "Your new Rails app is ready. Time to run 'bundle install'."
         
     |