diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-24 01:04:41 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-24 01:06:37 +0200 |
commit | 69abbe893413c99808c8cebd2f1d468c7921c573 (patch) | |
tree | d414a31d6e3b234f6d2af39084e3825f3d51eafa /activesupport | |
parent | 6f83a5036d8a9c3f8ed74755ff6d42bc3f6e9982 (diff) | |
download | rails-69abbe893413c99808c8cebd2f1d468c7921c573.tar.gz rails-69abbe893413c99808c8cebd2f1d468c7921c573.tar.bz2 rails-69abbe893413c99808c8cebd2f1d468c7921c573.zip |
Avoid using Pathname on Resolver and AS::Dependencies.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index f7b92cf896..7d5143ba37 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -353,14 +353,23 @@ module ActiveSupport #:nodoc: # Given +path+, a filesystem path to a ruby file, return an array of constant # paths which would cause Dependencies to attempt to load this file. def loadable_constants_for_path(path, bases = autoload_paths) - expanded_path = Pathname.new(path[/\A(.*?)(\.rb)?\Z/, 1]).expand_path + path = $1 if path =~ /\A(.*)\.rb\Z/ + expanded_path = File.expand_path(path) + paths = [] + + bases.each do |root| + expanded_root = File.expand_path(root) + next unless %r{\A#{Regexp.escape(expanded_root)}(/|\\)} =~ expanded_path + + nesting = expanded_path[(expanded_root.size)..-1] + nesting = nesting[1..-1] if nesting && nesting[0] == ?/ + next if nesting.blank? - bases.inject([]) do |paths, root| - expanded_root = Pathname.new(root).expand_path - nesting = expanded_path.relative_path_from(expanded_root).to_s - next paths if nesting =~ /\.\./ paths << nesting.camelize - end.uniq + end + + paths.uniq! + paths end # Search for a file in autoload_paths matching the provided suffix. |