Skip to content

Commit

Permalink
Actually add the file referenced in [7730]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7737 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
NZKoz committed Oct 4, 2007
1 parent 0a2404f commit a134f8f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions railties/lib/tasks/routes.rake
@@ -0,0 +1,17 @@
desc 'Print out all defined routes in match order, with names.'
task :routes => :environment do
routes = ActionController::Routing::Routes.routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
verb = route.conditions[:method].to_s.upcase
segs = route.segments.inject("") { |str,s| str << s.to_s }
segs.chop! if segs.length > 1
reqs = route.requirements.empty? ? "" : route.requirements.inspect
{:name => name, :verb => verb, :segs => segs, :reqs => reqs}
end
name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max
verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max
segs_width = routes.collect {|r| r[:segs]}.collect {|s| s.length}.max
routes.each do |r|
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}"
end
end

0 comments on commit a134f8f

Please sign in to comment.