aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorMark Turner <mark@amerine.net>2010-08-12 15:33:00 -0700
committerJosé Valim <jose.valim@gmail.com>2010-08-15 16:22:57 -0300
commit99f399752092310224fbfae05bf3a0b37e8dd725 (patch)
treea86f9b007dd51320d54206ec8915d7dcdc07a6b2 /railties
parent2f9f0829c6073531d8b35475fc164f914e2d37b0 (diff)
downloadrails-99f399752092310224fbfae05bf3a0b37e8dd725.tar.gz
rails-99f399752092310224fbfae05bf3a0b37e8dd725.tar.bz2
rails-99f399752092310224fbfae05bf3a0b37e8dd725.zip
make rake routes print the name of a Rack endpoint app [#5338 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/tasks/routes.rake8
1 files changed, 5 insertions, 3 deletions
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake
index a99232c4be..8b041c96c5 100644
--- a/railties/lib/rails/tasks/routes.rake
+++ b/railties/lib/rails/tasks/routes.rake
@@ -9,13 +9,15 @@ task :routes => :environment do
key_method = Hash.method_defined?('key') ? 'key' : 'index'
name = Rails.application.routes.named_routes.routes.send(key_method, route).to_s
reqs = route.requirements.empty? ? "" : route.requirements.inspect
- {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
+ app = route.app.to_s =~ /ActionDispatch.*/ ? "" : route.app.to_s
+ {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs, :app => app}
end
routes.reject!{ |r| r[:path] == "/rails/info/properties" } # skip the route if it's internal info route
name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max
verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max
path_width = routes.collect {|r| r[:path]}.collect {|s| s.length}.max
+ app_width = routes.collect {|r| r[:app]}.collect {|a| a.length}.max
routes.each do |r|
- puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
+ puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]} #{(r[:app].length > 0 ? '=> ' + r[:app] : '').ljust(app_width)}"
end
-end
+end \ No newline at end of file