Class: Facter::Util::DirectoryLoader

### Home Classes Methods

### In Files

- lib/facter/util/directory_loader.rb

### Parent

Object

### Namespace

- CLASS Facter::Util::DirectoryLoader::NoSuchDirectoryError

### Methods

- ::default_loader
- ::loader_for
- ::new
- #load

### 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::DirectoryLoader

### Constants

EXTERNAL_FACT_WEIGHT

  This value makes it highly likely that external facts will take precedence over all other facts

### Attributes

directory[R]

Directory for fact loading

### Public Class Methods

default_loader() click to toggle source

    # File lib/facter/util/directory_loader.rb, line 45
    def self.default_loader
      loaders = Facter::Util::Config.external_facts_dirs.collect do |dir|
        Facter::Util::DirectoryLoader.new(dir)
      end
      Facter::Util::CompositeLoader.new(loaders)
    end

loader_for(dir) click to toggle source

    # File lib/facter/util/directory_loader.rb, line 37
    def self.loader_for(dir)
      if File.directory?(dir)
        Facter::Util::DirectoryLoader.new(dir)
      else
        raise NoSuchDirectoryError
      end
    end

new(dir) click to toggle source

    # File lib/facter/util/directory_loader.rb, line 33
    def initialize(dir)
      @directory = dir
    end

### Public Instance Methods

load(collection) click to toggle source

Load facts from files in fact directory using the relevant parser classes to parse them.

    # File lib/facter/util/directory_loader.rb, line 54
    def load(collection)
      entries.each do |file|
        parser = Facter::Util::Parser.parser_for(file)
        if parser == nil
          next
        end

        data = parser.results
        if data == false
          Facter.warn "Could not interpret fact file #{file}"
        elsif data == {} or data == nil
          Facter.warn "Fact file #{file} was parsed but returned an empty data set"
        else
          data.each { |p,v| collection.add(p, :value => v) { has_weight(EXTERNAL_FACT_WEIGHT) } }
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.