diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-07-08 13:15:53 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-07-08 13:20:24 -0300 |
commit | 21c5bc9260a31440cad994f001c7ef6675d44a1d (patch) | |
tree | 05d89bd3017401391d1e17f78102c32708982d4b /railties/lib | |
parent | 15d80ebb0a59d04aa9d5032d93ff7e090a8d17a1 (diff) | |
download | rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.tar.gz rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.tar.bz2 rails-21c5bc9260a31440cad994f001c7ef6675d44a1d.zip |
Remove RoutesInspector from railties, since it was moved to AP
Changes introduced in 7404cda9f61e41d52ce244d60abbf598684a96c4.
Fix railties build.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application/routes_inspector.rb | 121 | ||||
-rw-r--r-- | railties/lib/rails/info_controller.rb | 1 |
2 files changed, 0 insertions, 122 deletions
diff --git a/railties/lib/rails/application/routes_inspector.rb b/railties/lib/rails/application/routes_inspector.rb deleted file mode 100644 index 6b2caf8277..0000000000 --- a/railties/lib/rails/application/routes_inspector.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'delegate' - -module Rails - class Application - class RouteWrapper < SimpleDelegator - def endpoint - rack_app ? rack_app.inspect : "#{controller}##{action}" - end - - def constraints - requirements.except(:controller, :action) - end - - def rack_app(app = self.app) - @rack_app ||= begin - class_name = app.class.name.to_s - if class_name == "ActionDispatch::Routing::Mapper::Constraints" - rack_app(app.app) - elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/ - app - end - end - end - - def verb - super.source.gsub(/[$^]/, '') - end - - def path - super.spec.to_s - end - - def name - super.to_s - end - - def reqs - @reqs ||= begin - reqs = endpoint - reqs += " #{constraints.inspect}" unless constraints.empty? - reqs - end - end - - def controller - requirements[:controller] || ':controller' - end - - def action - requirements[:action] || ':action' - end - - def internal? - path =~ %r{/rails/info.*|^#{Rails.application.config.assets.prefix}} - end - - def engine? - rack_app && rack_app.respond_to?(:routes) - end - end - - ## - # This class is just used for displaying route information when someone - # executes `rake routes`. People should not use this class. - class RoutesInspector # :nodoc: - def initialize - @engines = Hash.new - end - - def format(all_routes, filter = nil) - if filter - all_routes = all_routes.select{ |route| route.defaults[:controller] == filter } - end - - routes = collect_routes(all_routes) - - formatted_routes(routes) + - formatted_routes_for_engines - end - - def collect_routes(routes) - routes = routes.collect do |route| - RouteWrapper.new(route) - end.reject do |route| - route.internal? - end.collect do |route| - collect_engine_routes(route) - - {:name => route.name, :verb => route.verb, :path => route.path, :reqs => route.reqs } - end - end - - def collect_engine_routes(route) - name = route.endpoint - return unless route.engine? - return if @engines[name] - - routes = route.rack_app.routes - if routes.is_a?(ActionDispatch::Routing::RouteSet) - @engines[name] = collect_routes(routes.routes) - end - end - - def formatted_routes_for_engines - @engines.map do |name, routes| - ["\nRoutes for #{name}:"] + formatted_routes(routes) - end.flatten - end - - def formatted_routes(routes) - name_width = routes.map{ |r| r[:name].length }.max - verb_width = routes.map{ |r| r[:verb].length }.max - path_width = routes.map{ |r| r[:path].length }.max - - routes.map do |r| - "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}" - end - end - end - end -end diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb index 83ab8c7e9d..6276d7c0e4 100644 --- a/railties/lib/rails/info_controller.rb +++ b/railties/lib/rails/info_controller.rb @@ -15,7 +15,6 @@ class Rails::InfoController < ActionController::Base end def routes - inspector = Rails::Application::RoutesInspector.new inspector = ActionDispatch::Routing::RouteInspector.new @info = inspector.format(_routes.routes).join("\n") end |