1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix for routes task

This commit fixes formatting issue for `rake routes` task, when a section is shorter than a header.
This commit is contained in:
Sıtkı Bağdat 2013-11-21 01:52:09 +02:00
parent 64b9e93bb5
commit 6701b4cf41
4 changed files with 24 additions and 19 deletions

View file

@ -1,3 +1,7 @@
* Fix formatting for `rake routes` when a section is shorter than a header
*Sıtkı Bağdat*
* Take a hash with options inside array in #url_for * Take a hash with options inside array in #url_for
Example: Example:

View file

@ -179,7 +179,8 @@ module ActionDispatch
private private
def draw_section(routes) def draw_section(routes)
name_width, verb_width, path_width = widths(routes) header_lengths = ['Prefix', 'Verb', 'URI Pattern'].map(&:length)
name_width, verb_width, path_width = widths(routes).zip(header_lengths).map(&:max)
routes.map do |r| routes.map do |r|
"#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}" "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"

View file

@ -101,7 +101,7 @@ module ActionDispatch
assert_equal [ assert_equal [
"Prefix Verb URI Pattern Controller#Action", "Prefix Verb URI Pattern Controller#Action",
"root GET / pages#main" " root GET / pages#main"
], output ], output
end end