# >---------------------------------------------------------------------------< # # _____ _ _ # | __ \ (_) | /\ # | |__) |__ _ _| |___ / \ _ __ _ __ ___ # | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __| # | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \ # |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/ # | | | | # |_| |_| # # Application template generated by the rails_apps_composer gem. # Restrain your impulse to make changes to this file; instead, # make changes to the recipes in the rails_apps_composer gem. # # For more information, see: # https://github.com/RailsApps/rails_apps_composer/ # # Thank you to Michael Bleigh for leading the way with the RailsWizard gem. # # >---------------------------------------------------------------------------< # >----------------------------[ Initial Setup ]------------------------------< run 'bundle update' initializer 'generators.rb', <<-RUBY Rails.application.config.generators do |g| end RUBY @recipes = <%= resolve_recipes.map(&:key).inspect %> @prefs = <%= resolve_preferences %> @gems = <%= resolve_gems %> @diagnostics_recipes = <%= resolve_diagnostics_recipes %> @diagnostics_prefs = <%= resolve_diagnostics_prefs %> diagnostics = {} <%= render "helpers" %> if diagnostics_recipes.sort.include? recipes.sort diagnostics[:recipes] = 'success' say_wizard("WOOT! The recipes you've selected are known to work together.") else diagnostics[:recipes] = 'fail' say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m") say_wizard("Help us out by reporting whether this combination works or fails.") say_wizard("Please open an issue for rails_apps_composer on GitHub.") say_wizard("Your new application will contain diagnostics in its README file.") say_wizard("Continuing...") end # this application template only supports Rails version 3.1 and newer case Rails::VERSION::MAJOR.to_s when "3" case Rails::VERSION::MINOR.to_s when "0" say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." end else say_wizard "You are using Rails version #{Rails::VERSION::STRING} which is not supported. Try 3.1 or newer." raise StandardError.new "Rails #{Rails::VERSION::STRING} is not supported. Try 3.1 or newer." end say_wizard "Using rails_apps_composer recipes to generate an application." # >---------------------------[ Autoload Modules/Classes ]-----------------------------< inject_into_file 'config/application.rb', :after => 'config.autoload_paths += %W(#{config.root}/extras)' do <<-'RUBY' config.autoload_paths += %W(#{config.root}/lib) RUBY end # >---------------------------------[ Recipes ]----------------------------------< <% resolve_recipes.each do |recipe| %> <%= render 'recipe', recipe.get_binding %> <% end %> # >---------------------------------[ Diagnostics ]----------------------------------< # remove prefs which are diagnostically irrelevant redacted_prefs = prefs.clone redacted_prefs.delete(:git) redacted_prefs.delete(:dev_webserver) redacted_prefs.delete(:prod_webserver) redacted_prefs.delete(:templates) redacted_prefs.delete(:ban_spiders) redacted_prefs.delete(:jsruntime) redacted_prefs.delete(:rvmrc) redacted_prefs.delete(:prelaunch_branch) redacted_prefs.delete(:main_branch) if diagnostics_prefs.include? redacted_prefs diagnostics[:prefs] = 'success' else diagnostics[:prefs] = 'fail' end <% if custom_code? %># >-----------------------------[ Custom Code ]-------------------------------< <%= custom_code %><% end %> @current_recipe = nil # >-----------------------------[ Run 'Bundle Install' ]-------------------------------< say_wizard "Installing gems. This will take a while." if prefs.has_key? :bundle_path run "bundle install --without production --path #{prefs[:bundle_path]}" else run 'bundle install --without production' end # >-----------------------------[ Run 'After Bundler' Callbacks ]-------------------------------< say_wizard "Running 'after bundler' callbacks." require 'bundler/setup' if prefer :templates, 'haml' say_wizard "importing html2haml conversion tool" require 'haml/html' end if prefer :templates, 'slim' say_wizard "importing html2haml and haml2slim conversion tools" require 'haml/html' require 'haml2slim' end @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} # >-----------------------------[ Run 'After Everything' Callbacks ]-------------------------------< @current_recipe = nil say_wizard "Running 'after everything' callbacks." @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call} @current_recipe = nil if diagnostics[:recipes] == 'success' say_wizard("WOOT! The recipes you've selected are known to work together.") say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.") else say_wizard("\033[1m\033[36m" + "WARNING! The recipes you've selected might not work together." + "\033[0m") say_wizard("Help us out by reporting whether this combination works or fails.") say_wizard("Please open an issue for rails_apps_composer on GitHub.") say_wizard("Your new application will contain diagnostics in its README file.") end if diagnostics[:prefs] == 'success' say_wizard("WOOT! The preferences you've selected are known to work together.") say_wizard("If they don't, open an issue for rails_apps_composer on GitHub.") else say_wizard("\033[1m\033[36m" + "WARNING! The preferences you've selected might not work together." + "\033[0m") say_wizard("Help us out by reporting whether this combination works or fails.") say_wizard("Please open an issue for rails_apps_composer on GitHub.") say_wizard("Your new application will contain diagnostics in its README file.") end say_wizard "Finished running the rails_apps_composer app template." say_wizard "Your new Rails app is ready. Time to run 'bundle install'."