Parent

Class/Module Index [+]

Quicksearch

Facter::Util::Loader

Load facts on demand.

Public Class Methods

new() click to toggle source
# File lib/facter/util/loader.rb, line 8
def initialize
  @loaded = []
  @valid_path = {}
end

Public Instance Methods

load(fact) click to toggle source

Load all resolutions for a single fact.

# File lib/facter/util/loader.rb, line 14
def load(fact)
  # Now load from the search path
  shortname = fact.to_s.downcase
  load_env(shortname)

  filename = shortname + ".rb"
  search_path.each do |dir|
    # Load individual files
    file = File.join(dir, filename)

    load_file(file) if FileTest.exist?(file)

    # And load any directories matching the name
    factdir = File.join(dir, shortname)
    load_dir(factdir) if FileTest.directory?(factdir)
  end
end
load_all() click to toggle source

Load all facts from all directories.

# File lib/facter/util/loader.rb, line 33
def load_all
  return if defined?(@loaded_all)

  load_env

  search_path.each do |dir|
    next unless FileTest.directory?(dir)

    Dir.entries(dir).sort.each do |file|
      path = File.join(dir, file)
      if File.directory?(path)
        load_dir(path)
      elsif file =~ /\.rb$/
        load_file(File.join(dir, file))
      end
    end
  end

  @loaded_all = true
end
search_path() click to toggle source

The list of directories we're going to search through for facts.

# File lib/facter/util/loader.rb, line 55
def search_path
  result = []
  result += $LOAD_PATH.collect { |d| File.join(d, "facter") }
  if ENV.include?("FACTERLIB")
    result += ENV["FACTERLIB"].split(File::PATH_SEPARATOR)
  end

  # This allows others to register additional paths we should search.
  result += Facter.search_path

  result.select do |dir|
    good = valid_search_path? dir
    Facter.debugonce("Relative directory #{dir} removed from search path.") unless good
    good
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.