diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-06 11:19:24 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-06 11:19:30 -0200 |
commit | 3abb76824b87ad7142e43d764ef09bac73c2066d (patch) | |
tree | 8f93e58d4a39ed6c941a5a63daf20c978b32989e | |
parent | f18078475efce9eeef27d64044058539517b0260 (diff) | |
download | rails-3abb76824b87ad7142e43d764ef09bac73c2066d.tar.gz rails-3abb76824b87ad7142e43d764ef09bac73c2066d.tar.bz2 rails-3abb76824b87ad7142e43d764ef09bac73c2066d.zip |
Move table routes formatter class to the inspector and rename it
It feels more consistent to have this class called "HtmlTableFormatter",
and to have it here with the routes inspector and console formatter,
since it's used for both routing error exceptions and the rails info
page.
4 files changed, 20 insertions, 20 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb index 5c50f9ec6a..6bc5876b6c 100644 --- a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb @@ -89,23 +89,5 @@ module ActionDispatch ActionDispatch::Routing::RoutesInspector.new(@routes_app.routes.routes) end end - - class TableRoutesFormatter - def initialize(view) - @view = view - @buffer = [] - end - - def section(type, title, routes) - @buffer << %(<tr><th colspan="4">#{title}</th></tr>) - @buffer << @view.render(partial: "routes/route", collection: routes) - end - - def result - @view.raw @view.render(layout: "routes/route_wrapper") { - @view.raw @buffer.join("\n") - } - end - end end end diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb index 3e55b23025..61690d3e50 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.erb @@ -25,6 +25,6 @@ Routes match in priority from top to bottom </p> - <%= @routes_inspector.format(ActionDispatch::DebugExceptions::TableRoutesFormatter.new(self)) %> + <%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %> <% end %> </div> diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb index e607f8b8d5..9a5c3a5319 100644 --- a/actionpack/lib/action_dispatch/routing/inspector.rb +++ b/actionpack/lib/action_dispatch/routing/inspector.rb @@ -141,5 +141,23 @@ module ActionDispatch end end end + + class HtmlTableFormatter + def initialize(view) + @view = view + @buffer = [] + end + + def section(type, title, routes) + @buffer << %(<tr><th colspan="4">#{title}</th></tr>) + @buffer << @view.render(partial: "routes/route", collection: routes) + end + + def result + @view.raw @view.render(layout: "routes/route_wrapper") { + @view.raw @buffer.join("\n") + } + end + end end end diff --git a/railties/lib/rails/templates/rails/info/routes.html.erb b/railties/lib/rails/templates/rails/info/routes.html.erb index 30ea086ebb..2d8a190986 100644 --- a/railties/lib/rails/templates/rails/info/routes.html.erb +++ b/railties/lib/rails/templates/rails/info/routes.html.erb @@ -6,4 +6,4 @@ Routes match in priority from top to bottom </p> -<%= @routes_inspector.format(ActionDispatch::DebugExceptions::TableRoutesFormatter.new(self)) %> +<%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %> |