Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add headings to rake routes table

  • Loading branch information...
commit a6277629faf48469ac5ea4f6899b44a213d88c9f 1 parent 18c57c7
@steveklabnik steveklabnik authored
Showing with 19 additions and 3 deletions.
  1. +19 −3 actionpack/lib/action_dispatch/routing/inspector.rb
View
22 actionpack/lib/action_dispatch/routing/inspector.rb
@@ -90,6 +90,8 @@ def format(formatter, filter = nil)
routes_to_display = filter_routes(filter)
routes = collect_routes(routes_to_display)
+
+ formatter.header routes
@steveklabnik Collaborator

Uh oh. :( Hmmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
formatter.section routes
@engines.each do |name, engine_routes|
@@ -155,16 +157,30 @@ def section(routes)
@buffer << draw_section(routes)
end
+ def header(routes)
+ @buffer << draw_header(routes)
+ end
+
private
def draw_section(routes)
- name_width = routes.map { |r| r[:name].length }.max
- verb_width = routes.map { |r| r[:verb].length }.max
- path_width = routes.map { |r| r[:path].length }.max
+ name_width, verb_width, path_width = widths(routes)
routes.map do |r|
"#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
end
end
+
+ def draw_header(routes)
+ name_width, verb_width, path_width = widths(routes)
+
+ "#{"Prefix".rjust(name_width)} #{"Verb".ljust(verb_width)} #{"URI Pattern".ljust(path_width)} Controller#Action"
+ end
+
+ def widths(routes)
+ [routes.map { |r| r[:name].length }.max,
+ routes.map { |r| r[:verb].length }.max,
+ routes.map { |r| r[:path].length }.max]
+ end
end
class HtmlTableFormatter
Please sign in to comment.
Something went wrong with that request. Please try again.