Module: LegacyFacter
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/facter/custom_facts/util/config.rb,
lib/facter/custom_facts/util/loader.rb,
lib/facter/custom_facts/util/parser.rb,
lib/facter/custom_facts/util/values.rb,
lib/facter/custom_facts/util/confine.rb,
lib/facter/custom_facts/core/suitable.rb,
lib/facter/custom_facts/util/unix_root.rb,
lib/facter/custom_facts/core/resolvable.rb,
lib/facter/custom_facts/util/collection.rb,
lib/facter/custom_facts/util/windows_root.rb,
lib/facter/custom_facts/core/legacy_facter.rb,
lib/facter/custom_facts/util/normalization.rb,
lib/facter/custom_facts/core/directed_graph.rb,
lib/facter/custom_facts/util/nothing_loader.rb,
lib/facter/custom_facts/util/composite_loader.rb,
lib/facter/custom_facts/util/directory_loader.rb
Overview
A composite loader that allows for more than one default directory loader
Defined Under Namespace
Class Method Summary collapse
-
.[](name) ⇒ Facter::Util::Fact?
Returns a fact object by name.
-
.add(name, options = {}, { || ... }) ⇒ Facter::Util::Fact
Adds a resolution mechanism for a named fact.
-
.clear ⇒ void
Clears all cached values and removes all facts from memory.
-
.collection ⇒ LegacyFacter::Util::Collection
private
Accessor for the collection object which holds all the facts.
-
.define_fact(name, options = {}, &block) ⇒ Facter::Util::Fact
Define a new fact or extend an existing fact.
-
.each {|name, value| ... } ⇒ void
Iterates over fact names and values.
-
.fact(name) ⇒ Facter::Util::Fact?
Returns a fact object by name.
-
.flush ⇒ void
Flushes cached values for all facts.
-
.json? ⇒ Boolean
private
Returns whether the JSON “feature” is available.
-
.list ⇒ Array<String>
Lists all fact names.
-
.loadfacts ⇒ void
Loads all facts.
-
.reset ⇒ void
Removes all facts from memory.
-
.to_hash ⇒ Hash{String => Object}
Gets a hash mapping fact names to their values.
-
.value(name) ⇒ Object?
Gets the value for a fact.
Class Method Details
.[](name) ⇒ Facter::Util::Fact?
Returns a fact object by name. If you use this, you still have to call ‘value` on it to retrieve the actual value.
77 78 79 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 77 def self.[](name) collection.fact(name) end |
.add(name, options = {}, { || ... }) ⇒ Facter::Util::Fact
Adds a resolution mechanism for a named fact. This does not distinguish between adding a new fact and adding a new way to resolve a fact.
156 157 158 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 156 def self.add(name, = {}, &block) collection.add(name, , &block) end |
.clear ⇒ void
This method returns an undefined value.
Clears all cached values and removes all facts from memory.
182 183 184 185 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 182 def self.clear LegacyFacter.flush LegacyFacter.reset end |
.collection ⇒ LegacyFacter::Util::Collection
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.
Accessor for the collection object which holds all the facts
47 48 49 50 51 52 53 54 55 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 47 def self.collection unless defined?(@collection) && @collection @collection = LegacyFacter::Util::Collection.new( LegacyFacter::Util::Loader.new, LegacyFacter::Util::Config.ext_fact_loader ) end @collection end |
.define_fact(name, options = {}, &block) ⇒ Facter::Util::Fact
Define a new fact or extend an existing fact.
135 136 137 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 135 def self.define_fact(name, = {}, &block) collection.define_fact(name, , &block) end |
.each {|name, value| ... } ⇒ void
This method returns an undefined value.
Iterates over fact names and values
168 169 170 171 172 173 174 175 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 168 def self.each # Make sure all facts are loaded. collection.load_all collection.each do |*args| yield(*args) end end |
.fact(name) ⇒ Facter::Util::Fact?
Returns a fact object by name. If you use this, you still have to call ‘value` on it to retrieve the actual value.
82 83 84 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 82 def self.fact(name) collection.fact(name) end |
.flush ⇒ void
This method returns an undefined value.
Flushes cached values for all facts. This does not cause code to be reloaded; it only clears the cached results.
92 93 94 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 92 def self.flush collection.flush end |
.json? ⇒ Boolean
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 whether the JSON “feature” is available.
60 61 62 63 64 65 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 60 def self.json? require 'json' true rescue LoadError false end |
.list ⇒ Array<String>
Lists all fact names
101 102 103 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 101 def self.list collection.list end |
.loadfacts ⇒ void
This method returns an undefined value.
Loads all facts.
202 203 204 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 202 def self.loadfacts collection.load_all end |
.reset ⇒ void
This method returns an undefined value.
Removes all facts from memory. Use this when the fact code has changed on disk and needs to be reloaded.
193 194 195 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 193 def self.reset @collection = nil end |
.to_hash ⇒ Hash{String => Object}
Gets a hash mapping fact names to their values
121 122 123 124 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 121 def self.to_hash collection.load_all collection.to_hash end |
.value(name) ⇒ Object?
Gets the value for a fact. Returns ‘nil` if no such fact exists.
112 113 114 |
# File 'lib/facter/custom_facts/core/legacy_facter.rb', line 112 def self.value(name) collection.value(name) end |