diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-08-15 01:28:06 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-08-15 01:28:06 +0000 |
commit | 5baf7462c7a6dc6b30eec2b03735fee15e5b0dca (patch) | |
tree | 772db2310eeb4405a554ecb6970665fa3e73f9a5 /actionpack/lib | |
parent | 461dce13ae6db3db60256248c1696a6d1660b0c1 (diff) | |
download | rails-5baf7462c7a6dc6b30eec2b03735fee15e5b0dca.tar.gz rails-5baf7462c7a6dc6b30eec2b03735fee15e5b0dca.tar.bz2 rails-5baf7462c7a6dc6b30eec2b03735fee15e5b0dca.zip |
Add controller_paths variable to Routing; Assign Routing.controller_paths from initializer; fix script/about and rails info controller.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index e4d8253714..8c85c712a0 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -50,6 +50,10 @@ module ActionController module Routing SEPARATORS = %w( / ; . , ? ) + # The root paths which may contain controller files + mattr_accessor :controller_paths + self.controller_paths = [] + class << self def with_controllers(names) use_controllers! names @@ -58,7 +62,7 @@ module ActionController use_controllers! nil end - def normalize_paths(paths = $LOAD_PATH) + def normalize_paths(paths) # do the hokey-pokey of path normalization... paths = paths.collect do |path| path = path. @@ -80,16 +84,15 @@ module ActionController unless @possible_controllers @possible_controllers = [] - paths = $LOAD_PATH.select { |path| File.directory?(path) && path != "." } + paths = controller_paths.select { |path| File.directory?(path) && path != "." } seen_paths = Hash.new {|h, k| h[k] = true; false} normalize_paths(paths).each do |load_path| Dir["#{load_path}/**/*_controller.rb"].collect do |path| next if seen_paths[path.gsub(%r{^\.[/\\]}, "")] - + controller_name = path[(load_path.length + 1)..-1] - next unless path_may_be_controller?(controller_name) - + controller_name.gsub!(/_controller\.rb\Z/, '') @possible_controllers << controller_name end @@ -101,10 +104,6 @@ module ActionController @possible_controllers end - def path_may_be_controller?(path) - path !~ /(?:rails\/.*\/(?:examples|test))|(?:actionpack\/lib\/action_controller.rb$)|(?:app\/controllers)/o - end - def use_controllers!(controller_names) @possible_controllers = controller_names end |