Sha256: 0306a1f23b5065c9c8efc2ea73248249f00f44ca3367ba26b51d93b6c5e2daf3

Contents?: true

Size: 897 Bytes

Versions: 34

Compression:

Stored size: 897 Bytes

Contents

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

Version data entries

34 entries across 34 versions & 7 rubygems

Version Path
radiant-0.7.2 vendor/rails/railties/lib/tasks/routes.rake
vibes-bj-1.2.2 spec/rails_root/vendor/rails/railties/lib/tasks/routes.rake
vibes-bj-1.2.1 spec/rails_root/vendor/rails/railties/lib/tasks/routes.rake
rails-2.2.3 lib/tasks/routes.rake
webroar-0.2.2 src/admin_panel/vendor/rails/railties/lib/tasks/routes.rake
rails-2.3.3 lib/tasks/routes.rake
antfarm-0.3.0 rails/vendor/rails/railties/lib/tasks/routes.rake
antfarm-0.4.0 rails/vendor/rails/railties/lib/tasks/routes.rake
erails-2.1.2 lib/tasks/routes.rake
radiant-0.6.5.1 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.4 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.5 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.7 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.6 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.8 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.6.9 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.7.0 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.7.1 vendor/rails/railties/lib/tasks/routes.rake
radiant-0.8.0 vendor/rails/railties/lib/tasks/routes.rake
rails-1.2.5 lib/tasks/routes.rake