# File lib/action_dispatch/routing/inspector.rb, line 150 def initialize @buffer = [] end
# File lib/action_dispatch/routing/inspector.rb, line 166 def header(routes) @buffer << draw_header(routes) end
# File lib/action_dispatch/routing/inspector.rb, line 170 def no_routes @buffer << " You don't have any routes defined! Please add some routes in config/routes.rb. For more information about routes, see the Rails guide: http://guides.rubyonrails.org/routing.html. ".strip_heredoc end
# File lib/action_dispatch/routing/inspector.rb, line 154 def result @buffer.join("\n") end
# File lib/action_dispatch/routing/inspector.rb, line 162 def section(routes) @buffer << draw_section(routes) end
# File lib/action_dispatch/routing/inspector.rb, line 158 def section_title(title) @buffer << "\n#{title}:" end
# File lib/action_dispatch/routing/inspector.rb, line 189 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
# File lib/action_dispatch/routing/inspector.rb, line 181 def draw_section(routes) 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
# File lib/action_dispatch/routing/inspector.rb, line 195 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