Class: Facter::Util::Loader

### Home Classes Methods

### In Files

- lib/facter/util/loader.rb

### Parent

Object

### Methods

- ::new
- #load
- #load_all
- #search_path

### Files

- LICENSE
- Rakefile
- THANKS

### Class/Module Index

Quicksearch

- Facter
- Facter::Application
- Facter::Manufacturer
- Facter::Memory
- Facter::NetMask
- Facter::Util
- Facter::Util::CFPropertyList
- Facter::Util::CFPropertyList::CFArray
- Facter::Util::CFPropertyList::CFBoolean
- Facter::Util::CFPropertyList::CFData
- Facter::Util::CFPropertyList::CFDate
- Facter::Util::CFPropertyList::CFDictionary
- Facter::Util::CFPropertyList::CFInteger
- Facter::Util::CFPropertyList::CFReal
- Facter::Util::CFPropertyList::CFString
- Facter::Util::CFPropertyList::CFType
- Facter::Util::CFPropertyList::XML
- Facter::Util::Collection
- Facter::Util::CompositeLoader
- Facter::Util::Config
- Facter::Util::Confine
- Facter::Util::DirectoryLoader
- Facter::Util::DirectoryLoader::NoSuchDirectoryError
- Facter::Util::EC2
- Facter::Util::Fact
- Facter::Util::FileRead
- Facter::Util::IP
- Facter::Util::IP::Windows
- Facter::Util::IP::Windows::Bindings4
- Facter::Util::IP::Windows::Bindings6
- Facter::Util::Loader
- Facter::Util::Macaddress
- Facter::Util::Macaddress::Darwin
- Facter::Util::Macaddress::Windows
- Facter::Util::Macosx
- Facter::Util::MonkeyPatches
- Facter::Util::MonkeyPatches::Lines
- Facter::Util::NothingLoader
- Facter::Util::Parser
- Facter::Util::Parser::Base
- Facter::Util::Parser::JsonParser
- Facter::Util::Parser::KeyValuePairOutputFormat
- Facter::Util::Parser::NothingParser
- Facter::Util::Parser::PowershellParser
- Facter::Util::Parser::ScriptParser
- Facter::Util::Parser::TextParser
- Facter::Util::Parser::YamlParser
- Facter::Util::Processor
- Facter::Util::Registry
- Facter::Util::Resolution
- Facter::Util::SolarisZones
- Facter::Util::Uptime
- Facter::Util::Values
- Facter::Util::Virtual
- Facter::Util::Vlans
- Facter::Util::WMI
- Facter::Util::Xendomains
- Plist
- Plist::Emit
- Plist::Listener
- Plist::PArray
- Plist::PData
- Plist::PDate
- Plist::PDict
- Plist::PFalse
- Plist::PInteger
- Plist::PKey
- Plist::PList
- Plist::PReal
- Plist::PString
- Plist::PTag
- Plist::PTrue
- Plist::StreamParser
- CFFormatError
- CFPlistError
- CFTypeError
- IO
- Object
- String

No matching classes.

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