tuttle 0.0.6 → 0.0.8

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.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +17 -0
  3. data/Rakefile +0 -1
  4. data/app/controllers/tuttle/active_job_controller.rb +1 -0
  5. data/app/controllers/tuttle/active_model_serializers_controller.rb +1 -0
  6. data/app/controllers/tuttle/active_support_controller.rb +1 -0
  7. data/app/controllers/tuttle/application_controller.rb +19 -2
  8. data/app/controllers/tuttle/cancancan_controller.rb +2 -0
  9. data/app/controllers/tuttle/devise_controller.rb +1 -0
  10. data/app/controllers/tuttle/execjs_controller.rb +12 -0
  11. data/app/controllers/tuttle/gems_controller.rb +3 -2
  12. data/app/controllers/tuttle/home_controller.rb +1 -0
  13. data/app/controllers/tuttle/i18n_controller.rb +27 -0
  14. data/app/controllers/tuttle/paperclip_controller.rb +1 -0
  15. data/app/controllers/tuttle/rack_attack_controller.rb +26 -0
  16. data/app/controllers/tuttle/rack_mini_profiler_controller.rb +1 -0
  17. data/app/controllers/tuttle/rails_controller.rb +19 -5
  18. data/app/controllers/tuttle/request_controller.rb +1 -0
  19. data/app/controllers/tuttle/ruby_controller.rb +15 -2
  20. data/app/helpers/tuttle/application_helper.rb +64 -2
  21. data/app/models/tuttle/configuration_registry.rb +1 -0
  22. data/app/models/tuttle/version_detector.rb +1 -0
  23. data/app/views/layouts/tuttle/application.html.erb +22 -6
  24. data/app/views/tuttle/active_support/dependencies.html.erb +7 -7
  25. data/app/views/tuttle/active_support/inflectors.html.erb +1 -1
  26. data/app/views/tuttle/cancancan/index.html.erb +1 -1
  27. data/app/views/tuttle/cancancan/rule_tester.html.erb +3 -3
  28. data/app/views/tuttle/execjs/index.html.erb +87 -0
  29. data/app/views/tuttle/gems/http_clients.html.erb +13 -12
  30. data/app/views/tuttle/gems/index.html.erb +4 -4
  31. data/app/views/tuttle/gems/json.html.erb +10 -10
  32. data/app/views/tuttle/home/index.html.erb +6 -6
  33. data/app/views/tuttle/i18n/_translation_entry.html.erb +10 -0
  34. data/app/views/tuttle/i18n/index.html.erb +111 -0
  35. data/app/views/tuttle/i18n/localize.html.erb +53 -0
  36. data/app/views/tuttle/i18n/translations.html.erb +12 -0
  37. data/app/views/tuttle/rack_attack/index.html.erb +227 -0
  38. data/app/views/tuttle/rails/assets.html.erb +4 -4
  39. data/app/views/tuttle/rails/cache.html.erb +4 -8
  40. data/app/views/tuttle/rails/controllers.html.erb +54 -7
  41. data/app/views/tuttle/rails/database.html.erb +14 -1
  42. data/app/views/tuttle/rails/engines.html.erb +1 -1
  43. data/app/views/tuttle/rails/helpers.html.erb +1 -1
  44. data/app/views/tuttle/rails/index.html.erb +72 -19
  45. data/app/views/tuttle/rails/models.html.erb +150 -73
  46. data/app/views/tuttle/rails/routes.html.erb +10 -8
  47. data/app/views/tuttle/rails/schema_cache.html.erb +2 -2
  48. data/app/views/tuttle/ruby/constants.html.erb +29 -0
  49. data/app/views/tuttle/ruby/extensions.html.erb +24 -0
  50. data/app/views/tuttle/ruby/index.html.erb +21 -15
  51. data/app/views/tuttle/ruby/tuning.html.erb +6 -9
  52. data/config/routes.rb +15 -1
  53. data/lib/tuttle.rb +1 -0
  54. data/lib/tuttle/engine.rb +3 -4
  55. data/lib/tuttle/instrumenter.rb +3 -1
  56. data/lib/tuttle/middleware/request_profiler.rb +11 -11
  57. data/lib/tuttle/presenters/action_dispatch/routing/route_wrapper.rb +34 -2
  58. data/lib/tuttle/presenters/active_record/reflection_presenter.rb +54 -0
  59. data/lib/tuttle/presenters/active_support/callbacks.rb +26 -0
  60. data/lib/tuttle/presenters/base_presenter.rb +19 -0
  61. data/lib/tuttle/presenters/rack_mini_profiler/client_settings.rb +1 -0
  62. data/lib/tuttle/ruby_prof/fast_call_stack_printer.rb +2 -1
  63. data/lib/tuttle/version.rb +2 -1
  64. metadata +27 -18
@@ -0,0 +1,12 @@
1
+ <h1>Translations for <code><%= I18n.locale.inspect %></code></h1>
2
+
3
+ <p>
4
+ Available locales:
5
+ <% I18n.available_locales.sort.each do |hl| %>
6
+ <%= link_to hl.inspect, i18n_translations_path(hl: hl), class:"btn btn-xs #{ I18n.locale == hl ? 'btn-success' : 'btn-default'}", role: "button" %>
7
+ <% end %>
8
+ </p>
9
+
10
+ <ul>
11
+ <%= render partial: 'translation_entry', collection: @translations[I18n.locale].to_a.sort_by { |entry| "#{entry[1].is_a?(Hash)}-#{entry[0]}" } %>
12
+ </ul>
@@ -0,0 +1,227 @@
1
+ <style>
2
+ table td.noresults { background-color: lightgoldenrodyellow; text-align: center; }
3
+ </style>
4
+ <h1>Rack::Attack</h1>
5
+
6
+ <p>
7
+ <a href="https://github.com/kickstarter/rack-attack">Rack::Attack</a> is middleware for blocking & throttling abusive requests.
8
+ </p>
9
+
10
+ <div class="panel panel-default">
11
+ <div class="panel-heading">
12
+ <h2 class="panel-title">Configuration</h2>
13
+ </div>
14
+ <div class="panel-body">
15
+ <dl>
16
+ <dt>Version</dt>
17
+ <dd><code><%= Rack::Attack::VERSION %></code></dd>
18
+ <dt>Cache Class</dt>
19
+ <dd><code><%= Rack::Attack.cache.class %></code></dd>
20
+ <dt>Cache Prefix</dt>
21
+ <dd><code><%= Rack::Attack.cache.prefix %></code></dd>
22
+ <dt>Notifier</dt>
23
+ <dd><code><%= Rack::Attack.notifier %></code></dd>
24
+ <dt>Blocklisted Response</dt>
25
+ <dd><%= display_source_locaction(*Rack::Attack.blocklisted_response.source_location) %></dd>
26
+ <dt>Throttled Response</dt>
27
+ <dd><%= display_source_locaction(*Rack::Attack.throttled_response.source_location) %></dd>
28
+ </dl>
29
+ </div>
30
+ </div>
31
+
32
+ <div class="panel panel-default">
33
+ <div class="panel-heading">
34
+ <h2 class="panel-title">Current request environment</h2>
35
+ </div>
36
+ <div class="panel-body">
37
+ <table class="table table-compact">
38
+ <tr>
39
+ <th>Name</th>
40
+ <th>Value</th>
41
+ </tr>
42
+ <tr>
43
+ <td>Request IP</td>
44
+ <td><%= request.ip %></td>
45
+ </tr>
46
+ <tr>
47
+ <td>Request Host</td>
48
+ <td><%= request.host %></td>
49
+ </tr>
50
+
51
+ <% @rack_attack_env_settings.each do |k| %>
52
+ <tr>
53
+ <td><%= k %></td>
54
+ <td>
55
+ <% if request.env[k].is_a?(Hash) %>
56
+ <% request.env[k].each do |k2, v2| %>
57
+ <%= k2.to_s %> : <%= v2.inspect %><br/>
58
+ <% end %>
59
+ <% else %>
60
+ <%= value_inspect(request.env[k], hide_nil: false) %>
61
+ <% end %>
62
+ </td>
63
+ </tr>
64
+ <% end %>
65
+ </table>
66
+ </div>
67
+ </div>
68
+
69
+ <div class="panel panel-default">
70
+ <div class="panel-heading">
71
+ <h2 class="panel-title">Throttles <span class="badge"><%= @throttles.size %></span></h2>
72
+ </div>
73
+ <div class="panel-body">
74
+ <table class="table table-compact">
75
+ <tr>
76
+ <th>Name</th>
77
+ <th>Limit</th>
78
+ <th>Period</th>
79
+ <th>Source Location</th>
80
+ </tr>
81
+ <% if @throttles.size == 0 %>
82
+ <tr>
83
+ <td colspan="5" class="noresults">No throttles registered</td>
84
+ </tr>
85
+ <% else %>
86
+ <% @throttles.values.each do |throttle| %>
87
+ <tr>
88
+ <td><%= throttle.name %></td>
89
+ <td>
90
+ <% if throttle.limit.respond_to?(:call) %>
91
+ <%= display_source_locaction(*throttle.limit.source_location) %>
92
+ <% else %>
93
+ <%= throttle.limit %>
94
+ <% end %>
95
+ </td>
96
+ <td>
97
+ <% if throttle.period.respond_to?(:call) %>
98
+ <%= display_source_locaction(*throttle.period.source_location) %>
99
+ <% else %>
100
+ <%= throttle.period %>
101
+ <% end %>
102
+ </td>
103
+ <td>
104
+ <%= display_source_locaction(*throttle.block.source_location) %>
105
+ </td>
106
+ </tr>
107
+ <% end %>
108
+ <% end %>
109
+ </table>
110
+ </div>
111
+ </div>
112
+
113
+ <div class="panel panel-default">
114
+ <div class="panel-heading">
115
+ <h2 class="panel-title">Safelists <span class="badge"><%= @safelists.size %></span></h2>
116
+ </div>
117
+ <div class="panel-body">
118
+ <table class="table table-compact nowrap">
119
+ <tr>
120
+ <th>Name</th>
121
+ <th>Source Location</th>
122
+ </tr>
123
+ <% if @safelists.size == 0 %>
124
+ <tr>
125
+ <td colspan="2" class="noresults">No safelists registered</td>
126
+ </tr>
127
+ <% else %>
128
+ <% @safelists.values.each do |safelist| %>
129
+ <tr>
130
+ <td><%= safelist.name %></td>
131
+ <td><%= display_source_locaction(*safelist.block.source_location) %></td>
132
+ </tr>
133
+ <% end %>
134
+ <% end %>
135
+ </table>
136
+ </div>
137
+ </div>
138
+
139
+ <div class="panel panel-default">
140
+ <div class="panel-heading">
141
+ <h2 class="panel-title">Blocklists <span class="badge"><%= @blocklists.size %></span></h2>
142
+ </div>
143
+ <div class="panel-body">
144
+ <table class="table table-compact">
145
+ <tr>
146
+ <th>Name</th>
147
+ <th>Source Location</th>
148
+ </tr>
149
+ <% if @blocklists.size == 0 %>
150
+ <tr>
151
+ <td colspan="2" class="noresults">No blocklists registered</td>
152
+ </tr>
153
+ <% else %>
154
+ <% @blocklists.values.each do |blocklists| %>
155
+ <tr>
156
+ <td><%= blocklists.name %></td>
157
+ <td><%= display_source_locaction(*blocklists.block.source_location) %></td>
158
+ </tr>
159
+ <% end %>
160
+ <% end %>
161
+ </table>
162
+ </div>
163
+ </div>
164
+
165
+ <div class="panel panel-default">
166
+ <div class="panel-heading">
167
+ <h2 class="panel-title">Tracks <span class="badge"><%= @tracks.size %></span></h2>
168
+ </div>
169
+ <div class="panel-body">
170
+ <table class="table table-compact">
171
+ <tr>
172
+ <th>Name</th>
173
+ <th>Type</th>
174
+ <th>Filter Class</th>
175
+ <th>Limit</th>
176
+ <th>Period</th>
177
+ <th>Source Location</th>
178
+ </tr>
179
+ <% if @tracks.size == 0 %>
180
+ <tr>
181
+ <td colspan="6" class="noresults">No blocklists registered</td>
182
+ </tr>
183
+ <% else %>
184
+ <% @tracks.values.each do |track| %>
185
+ <tr>
186
+ <td><%= track.filter.name %></td>
187
+ <td><%= track.filter.type %></td>
188
+ <td><%= track.filter.class %></td>
189
+ <% # TODO presenter needed here %>
190
+ <% if track.filter.class == Rack::Attack::Throttle %>
191
+ <td><%= track.filter.limit rescue nil %></td>
192
+ <td><%= track.filter.period rescue nil %></td>
193
+ <% else %>
194
+ <td colspan="2"></td>
195
+ <% end %>
196
+ <td><%= display_source_locaction(*track.filter.block.source_location) rescue 'No Source Location' %></td>
197
+ </tr>
198
+ <% end %>
199
+ <% end %>
200
+ </table>
201
+ </div>
202
+ </div>
203
+
204
+ <div class="panel panel-default">
205
+ <div class="panel-heading">
206
+ <h2 class="panel-title">Notification Listeners <span class="badge"><%= @asn_listeners.size %></span></h2>
207
+ </div>
208
+ <div class="panel-body">
209
+ <p>ActiveSupport::Notification listeners for 'rack.attack'</p>
210
+ <table class="table table-compact">
211
+ <tr>
212
+ <th>Source Location</th>
213
+ </tr>
214
+ <% if @asn_listeners.size == 0 %>
215
+ <tr>
216
+ <td colspan="1" class="noresults">None registered</td>
217
+ </tr>
218
+ <% else %>
219
+ <% @asn_listeners.each do |listener| %>
220
+ <tr>
221
+ <td><%= display_source_locaction(*listener.instance_variable_get(:@delegate).source_location) rescue 'Unknown' %></td>
222
+ </tr>
223
+ <% end %>
224
+ <% end %>
225
+ </table>
226
+ </div>
227
+ </div>
@@ -83,7 +83,7 @@
83
83
  <td><code><%= @assets_config.unknown_asset_fallback.inspect %></code></td>
84
84
  <td></td>
85
85
  </tr>
86
- <% if Sprockets::Rails::VERSION >= '3.6.2' %>
86
+ <% if Sprockets::VERSION >= '3.6.2' %>
87
87
  <tr>
88
88
  <td>config.assets.check_precompiled_asset</td>
89
89
  <td><code><%= @assets_config.check_precompiled_asset.inspect %></code></td>
@@ -156,11 +156,11 @@
156
156
  </p>
157
157
  <pre>
158
158
  <% @sprockets_env.paths.each do |asset_path| -%>
159
- <%= asset_path.to_s %>
159
+ <%= display_path(asset_path.to_s) %>
160
160
  <% end -%>
161
161
  </pre>
162
162
 
163
- <h3>Precompiles - Explicit and Patterns (<%= @assets_config.precompile.length %> items)</h3>
163
+ <h3>Precompiles - Explicit and Patterns <span class="badge"><%= @assets_config.precompile.length %> items</span></h3>
164
164
  <ul>
165
165
  <% @assets_config.precompile.each do |asset_path| %>
166
166
  <li><%= asset_path %></li>
@@ -181,7 +181,7 @@
181
181
  <% # Only supported in Rails 4.1+ %>
182
182
  <% if Rails.application.respond_to?(:precompiled_assets) %>
183
183
  <% all_precompiles = Rails.application.precompiled_assets %>
184
- <h3>All precompiled (<%= all_precompiles.length %> assets)</h3>
184
+ <h3>All precompiled <span class="badge"><%= all_precompiles.length %> assets</span></h3>
185
185
  <ul>
186
186
  <% all_precompiles.sort.each do |asset_path| %>
187
187
  <li><%= asset_path %></li>
@@ -72,7 +72,9 @@
72
72
  # Action caching available? <%= !!defined?(ActionController::Caching::Actions)
73
73
  -%>
74
74
 
75
- <%- if @cache.is_a?(ActiveSupport::Cache::MemoryStore) %>
75
+ <%- if @cache.is_a?(ActiveSupport::Cache::NullStore) %>
76
+ <p>NullStore has no configuration options</p>
77
+ <%- elsif @cache.is_a?(ActiveSupport::Cache::MemoryStore) %>
76
78
  <%= render partial: 'cache_memory_store' %>
77
79
  <%- elsif @cache.is_a?(ActiveSupport::Cache::MemCacheStore) ||
78
80
  defined?(::ActiveSupport::Cache::DalliStore) && @cache.is_a?(ActiveSupport::Cache::DalliStore) %>
@@ -82,14 +84,8 @@
82
84
  Rails FileStore options<br />
83
85
  &nbsp;&nbsp;<code>:cache_path =&gt; <%= @cache.cache_path %></code>
84
86
  </p>
85
- <%- elsif @cache.is_a?(ActiveSupport::Cache::NullStore) %>
86
- <p>
87
- NullStore has no configuration options
88
- </p>
89
87
  <%- else %>
90
- <p>
91
- Unknown cache store.
92
- </p>
88
+ <p>Unknown cache store.</p>
93
89
  <%- end %>
94
90
 
95
91
  <% # DISABLED render partial: 'cache_monitor' %>
@@ -1,10 +1,57 @@
1
- <h2>Controllers and public instance methods (<%= @controllers.size %>)</h2>
2
- <pre>
1
+ <h2>Controllers <span class="badge"><%= @controllers.size %></span> and action methods <span class="badge"><%= @controllers.map(&:action_methods).map(&:size).sum %></span></h2>
2
+
3
3
  <% @controllers.each do |controller| %>
4
- <%= controller.inspect %>
5
- <%- controller.action_methods.sort.each do |method| %>
6
- <%= method.to_s %>
7
- <% end %>
4
+ <%- controller_instance = controller.new %>
5
+ <%- controller_path = controller.controller_path %>
6
+ <%- callback_chain_presenter = Tuttle::Presenters::ActiveSupport::Callbacks::CallbackChainWrapper.new(controller._process_action_callbacks) %>
7
+
8
+ <h4><%= controller.inspect %> (<code><%= controller.controller_path %></code>) &lt; <%= controller.superclass %></h4>
8
9
 
10
+ <details>
11
+ <summary>Callbacks <span class="badge"><%= callback_chain_presenter.size %></span></summary>
12
+ <table class="table table-condensed">
13
+ <thead>
14
+ <tr>
15
+ <th>Name</th>
16
+ <th>Kind</th>
17
+ <th>Location</th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <% # TODO: show if/unless details %>
22
+ <%- callback_chain_presenter.each do |cb| %>
23
+ <tr>
24
+ <td><code><%= cb.filter.inspect %></code></td>
25
+ <td><code><%= cb.kind.inspect %></code></td>
26
+ <td><code><%= display_source_locaction(*cb.safe_source_location(controller_instance)) %></code></td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ </table>
31
+ </details>
32
+
33
+ <%- action_methods = controller.action_methods %>
34
+ <h5>Actions <span class="badge"><%= action_methods.size %></span></h5>
35
+ <table class="table table-condensed">
36
+ <tbody>
37
+ <%- action_methods.each do |method| %>
38
+ <% # TODO controller and action layout, template exists? %>
39
+ <% # TODO routes to actions %>
40
+ <tr>
41
+ <td width="50%"><code><%= method.to_s %></code></td>
42
+ <td width="50%" class="nowrap">
43
+ <%- route_matches = @routes.select { |r| r.controller == controller_path && r.action == method.to_s } %>
44
+ <% if route_matches.size > 0 %>
45
+ <% route_matches.each do |route| %>
46
+ <%= link_to "#{ route.verb } #{ route.path }", rails_routes_path(anchor: "route_#{route.precedence}") %><br/>
47
+ <% end %>
48
+ <% else %>
49
+ <code><%= truth_label(false, nil, 'unrouted') %></code>
50
+ <% end %>
51
+ </td>
52
+ </tr>
53
+ <% end %>
54
+ </tbody>
55
+ </table>
9
56
  <% end %>
10
- </pre>
57
+
@@ -15,6 +15,19 @@
15
15
  <p>Pool size = <%= ActiveRecord::Base.connection_pool.size rescue 'N/A' %></p>
16
16
  <p>Schema Cache size = <%= @conn.schema_cache.size rescue 'N/A' %></p>
17
17
 
18
+ <%- if defined?(PG::Connection) && ActiveRecord::Base.connection.raw_connection.class <= PG::Connection -%>
19
+ <h3>PostgreSQL Prepared Statements</h3>
20
+ <table class="table table-condensed">
21
+ <% statements = ActiveRecord::Base.connection.raw_connection.exec("select * from pg_prepared_statements order by prepare_time;").to_a %>
22
+ <% statements.each do |row| %>
23
+ <tr>
24
+ <td><%= row["name"] %></td>
25
+ <td><%= row["statement"] %></td>
26
+ </tr>
27
+ <% end %>
28
+ </table>
29
+ <% end %>
30
+
18
31
  <%- if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && @conn.class <= ActiveRecord::ConnectionAdapters::PostgreSQLAdapter -%>
19
32
 
20
33
  <%- statement_pool = @conn.instance_variable_get(:@statements) %>
@@ -55,7 +68,7 @@
55
68
  </ul>
56
69
  <%- end -%>
57
70
 
58
- <h3>Tables (Data Sources) (<%= @data_sources.size %>)</h3>
71
+ <h3>Tables (Data Sources) <span class="badge"><%= @data_sources.size %></span></h3>
59
72
  <p><%= @data_sources %></p>
60
73
 
61
74
  <h3>Native DB Types Supported</h3>
@@ -14,7 +14,7 @@
14
14
  <table class="table table-condensed" style="width: auto;">
15
15
  <tr>
16
16
  <th>Engine root path</th>
17
- <td><%= engine.root %></td>
17
+ <td><code><%= display_path(engine.root.to_s) %></code></td>
18
18
  </tr>
19
19
  <tr>
20
20
  <th>Paths</th>
@@ -1,4 +1,4 @@
1
- <h2>Helpers (<%= @helpers.size %>)</h2>
1
+ <h2>Helpers <span class="badge"><%= @helpers.size %></span></h2>
2
2
 
3
3
  helpers_path: <%= ::ApplicationController.helpers_path %><br/>
4
4
  include_all_helpers: <%= ::ApplicationController.include_all_helpers %><br/>
@@ -64,20 +64,22 @@ Log Level = <%= Rails.configuration.log_level %>
64
64
  <p>
65
65
  Rails will load code based on the configured load paths with the
66
66
  help of ActiveSupport.
67
- <ul>
68
- <li>
69
- Autoload - Files will be searched here to auto
70
- load classes based on naming convention
71
- </li>
72
- <li>
73
- Autoload Once - A subset of autoload that will not be reloaded
74
- when class caching is disabled (default for development)
75
- </li>
76
- <li>
77
- Eager Load - All classes here will be loaded when eager loading
78
- is configured (default for production)
79
- </li>
80
- </ul>
67
+ </p>
68
+ <ul>
69
+ <li>
70
+ Autoload - Files will be searched here to auto
71
+ load classes based on naming convention
72
+ </li>
73
+ <li>
74
+ Autoload Once - A subset of autoload that will not be reloaded
75
+ when class caching is disabled (default for development)
76
+ </li>
77
+ <li>
78
+ Eager Load - All classes here will be loaded when eager loading
79
+ is configured (default for production)
80
+ </li>
81
+ </ul>
82
+ <p>
81
83
  The runtime load paths are determined by configuration (typically in
82
84
  <code>application.rb</code>), Rails' default load paths
83
85
  (e.g. <code>app/*</code>), paths contributed by Engines, and direct API
@@ -110,7 +112,7 @@ Log Level = <%= Rails.configuration.log_level %>
110
112
  </tr>
111
113
  <% all_load_paths.each do |path| %>
112
114
  <tr>
113
- <td><%= path %></td>
115
+ <td><%= display_path(path) %></td>
114
116
  <td><%= truth_label(all_autoload_paths.include?(path)) %></td>
115
117
  <td><%= truth_label(all_autoload_once_paths.include?(path)) %></td>
116
118
  <td><%= truth_label(config_eager_load_paths.include?(path)) %></td>
@@ -122,11 +124,29 @@ Log Level = <%= Rails.configuration.log_level %>
122
124
  </table>
123
125
  </div>
124
126
  <div class="tab-pane" id="initializers">
125
- <p>Rails initializers are blocks of code that run during application initialization.</p>
126
- <p>Initializers can be provided by any Railtie, which includes Rails components themselves as well as many Gems.</p>
127
+ <p>
128
+ <a href="<%= rails_guides_versioned_url('configuring.html#using-initializer-files') %>">Rails initializers</a> are blocks of code that run during application initialization.
129
+ Initializers can be provided by any Railtie, which includes Rails components themselves as well as many Gems.
130
+ </p>
131
+ <p>
132
+ All files in your <code>config/initializers</code> directory will be loaded by the <code>:load_config_initializers</code> initializer
133
+ </p>
134
+
135
+ <%
136
+ special_hooks = [:bootstrap_hook, :run_prepare_callbacks, :eager_load!, :finisher_hook]
137
+ %>
138
+
139
+ <p></p>
127
140
  <table class="table table-condensed">
128
- <tr><th>#</th><th>Name</th><th>Context Class</th><th>Group</th><th>After</th><th>Before</th></tr>
129
- <%- idx = 0 %>
141
+ <tr><th>#</th><th>Name</th><th>Context Class or File Location</th><th>Group</th><th>After</th><th>Before</th></tr>
142
+ <%- idx = 0 %>
143
+ <% ActiveSupport.instance_variable_get(:@load_hooks)[:before_configuration].each do |k, _v| %>
144
+ <tr>
145
+ <td></td>
146
+ <td>:before_configuration hook</td>
147
+ <td colspan="4"><code><%= display_source_locaction(*k.source_location) %></code></td>
148
+ </tr>
149
+ <% end %>
130
150
  <%- Rails.application.initializers.tsort_each do |initializer| %>
131
151
  <%- options = initializer.instance_variable_get('@options'.freeze) %>
132
152
  <tr>
@@ -137,9 +157,42 @@ Log Level = <%= Rails.configuration.log_level %>
137
157
  <td><%= options.try(:[],:after).try(:inspect) %></td>
138
158
  <td><%= options.try(:[],:before).try(:inspect) %></td>
139
159
  </tr>
160
+ <% if initializer.name == :load_config_initializers %>
161
+ <% initializer.instance_variable_get('@context'.freeze).config.paths["config/initializers"].existent.sort.each do |initializer_file| %>
162
+ <tr>
163
+ <td></td>
164
+ <td>--&gt; config_initializer file</td>
165
+ <td colspan="4"><code><%= file_location(initializer_file) %></code></td>
166
+ </tr>
167
+ <% end %>
168
+ <% end %>
169
+ <% if special_hooks.include?(initializer.name) %>
170
+ <%
171
+ # TODO: Add special handling blocks for these cases
172
+ special_hook_load = case initializer.name
173
+ when :bootstrap_hook
174
+ :before_initialize
175
+ when :run_prepare_callbacks
176
+ # TODO: this is not correct. to_prepare blocks are not in load_hooks
177
+ :to_prepare
178
+ when :eager_load!
179
+ :before_eager_load
180
+ when :finisher_hook
181
+ :after_initialize
182
+ end
183
+ %>
184
+ <% ActiveSupport.instance_variable_get(:@load_hooks)[special_hook_load].each do |k, _v| %>
185
+ <tr>
186
+ <td></td>
187
+ <td>--&gt; <%= special_hook_load.inspect %></td>
188
+ <td colspan="4"><code><%= display_source_locaction(*k.source_location) %></code></td>
189
+ </tr>
190
+ <%- end %>
191
+ <%- end %>
140
192
  <%- end %>
141
193
  </table>
142
194
  </div>
195
+
143
196
  <div class="tab-pane" id="middleware">
144
197
  <p>The Rack middleware configuration shows the modules in the Rack stack that will process the request and response.</p>
145
198
  <ol>