lib/facter/util/loader.rb in facter-1.6.18 vs lib/facter/util/loader.rb in facter-1.7.0.rc1

- old
+ new

@@ -1,12 +1,15 @@ require 'facter' +require 'pathname' +require 'facter/util/directory_loader' # Load facts on demand. class Facter::Util::Loader def initialize @loaded = [] + @valid_path = {} end # Load all resolutions for a single fact. def load(fact) # Now load from the search path @@ -51,17 +54,28 @@ # The list of directories we're going to search through for facts. def search_path result = [] result += $LOAD_PATH.collect { |d| File.join(d, "facter") } if ENV.include?("FACTERLIB") - result += ENV["FACTERLIB"].split(":") + result += ENV["FACTERLIB"].split(File::PATH_SEPARATOR) end # This allows others to register additional paths we should search. result += Facter.search_path - result + result.select do |dir| + good = valid_search_path? dir + Facter.debugonce("Relative directory #{dir} removed from search path.") unless good + good + end end + + def valid_search_path?(path) + return @valid_path[path] unless @valid_path[path].nil? + + return @valid_path[path] = Pathname.new(path).absolute? + end + private :valid_search_path? private def load_dir(dir) return if dir =~ /\/\.+$/ or dir =~ /\/util$/ or dir =~ /\/lib$/