lib/polyglot.rb in polyglot-0.3.3 vs lib/polyglot.rb in polyglot-0.3.4
- old
+ new
@@ -22,19 +22,21 @@
}
end
def self.find(file, *options, &block)
is_absolute = Pathname.new(file).absolute?
- (is_absolute ? [""] : $:).each{|lib|
+ is_dot_relative = file =~ /\.[\/\\]/
+ paths = is_absolute ? [''] : Array(is_dot_relative ? '.' : nil) + $:
+ paths.each do |lib|
base = is_absolute ? "" : lib+File::SEPARATOR
# In Windows, repeated SEPARATOR chars have a special meaning, avoid adding them
matches = Dir["#{base}#{file}{,.#{@registrations.keys*',.'}}"]
# Revisit: Should we do more do if more than one candidate found?
$stderr.puts "Polyglot: found more than one candidate for #{file}: #{matches*", "}" if matches.size > 1
if path = matches[0]
return [ path, @registrations[path.gsub(/.*\./,'')]]
end
- }
+ end
return nil
end
def self.load(*a, &b)
file = a[0].to_str