forked from RailsApps/rails_apps_composer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.erb
151 lines (126 loc) · 5.95 KB
/
layout.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# >---------------------------------------------------------------------------<
#
# _____ _ _
# | __ \ (_) | /\
# | |__) |__ _ _| |___ / \ _ __ _ __ ___
# | _ // _` | | / __| / /\ \ | '_ \| '_ \/ __|
# | | \ \ (_| | | \__ \/ ____ \| |_) | |_) \__ \
# |_| \_\__,_|_|_|___/_/ \_\ .__/| .__/|___/
# | | | |
# |_| |_|
#
# Template generated by rails_apps_composer. For more information, see:
# https://github.com/RailsApps/rails_apps_composer/
# Thank you to Michael Bleigh for leading the way with the RailsWizard gem.
#
# >---------------------------------------------------------------------------<
# >----------------------------[ Initial Setup ]------------------------------<
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'."