1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Avoid using Pathname on Resolver and AS::Dependencies.

This commit is contained in:
José Valim 2010-06-24 01:04:41 +02:00
parent 6f83a5036d
commit 69abbe8934
2 changed files with 16 additions and 7 deletions

View file

@ -99,7 +99,7 @@ module ActionView
def initialize(path)
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
super()
@path = Pathname.new(path).expand_path
@path = File.expand_path(path)
end
def eql?(resolver)

View file

@ -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.