Class: LegacyFacter::Util::DirectoryLoader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/custom_facts/util/directory_loader.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: NoSuchDirectoryError

Constant Summary collapse

EXTERNAL_FACT_WEIGHT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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

10_000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir = LegacyFacter::Util::Config.external_facts_dirs, weight = EXTERNAL_FACT_WEIGHT) ⇒ DirectoryLoader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DirectoryLoader.



35
36
37
38
39
# File 'lib/facter/custom_facts/util/directory_loader.rb', line 35

def initialize(dir = LegacyFacter::Util::Config.external_facts_dirs, weight = EXTERNAL_FACT_WEIGHT)
  @directories = [dir].flatten
  @weight = weight
  @log ||= Facter::Log.new(self)
end

Instance Attribute Details

#directoriesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Directory for fact loading



33
34
35
# File 'lib/facter/custom_facts/util/directory_loader.rb', line 33

def directories
  @directories
end

Instance Method Details

#load(collection) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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



43
44
45
46
47
48
49
50
51
# File 'lib/facter/custom_facts/util/directory_loader.rb', line 43

def load(collection)
  weight = @weight

  searched_facts, cached_facts = load_directory_entries(collection)

  load_cached_facts(collection, cached_facts, weight)

  load_searched_facts(collection, searched_facts, weight)
end