lib/polyglot.rb in polyglot-0.2.8 vs lib/polyglot.rb in polyglot-0.2.9

- old
+ new

@@ -2,10 +2,12 @@ require 'pathname' module Polyglot @registrations ||= {} # Guard against reloading @loaded ||= {} + + class PolyglotLoadError < LoadError; end class NestedLoadError < LoadError def initialize le @le = le end @@ -25,11 +27,11 @@ extensions = @registrations.keys*"," is_absolute = Pathname.new(file).absolute? (is_absolute ? [""] : $:).each{|lib| base = is_absolute ? "" : lib+File::SEPARATOR # In Windows, repeated SEPARATOR chars have a special meaning, avoid adding them - matches = Dir[base+file+".{"+extensions+"}"] + matches = Dir[(base+file+".{"+extensions+"}").to_s] # 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 @@ -52,10 +54,10 @@ else msg = "Failed to load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}" if defined?(MissingSourceFile) raise MissingSourceFile.new(msg, file) else - raise LoadError.new(msg) + raise PolyglotLoadError.new(msg) end end end end end