Class: Facter::FactLoader
- Inherits:
-
Object
- Object
- Facter::FactLoader
- Includes:
- Singleton
- Defined in:
- lib/facter/framework/core/fact_loaders/fact_loader.rb
Instance Attribute Summary collapse
-
#external_facts ⇒ Object
readonly
Returns the value of attribute external_facts.
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
-
#internal_facts ⇒ Object
readonly
Returns the value of attribute internal_facts.
Instance Method Summary collapse
-
#initialize ⇒ FactLoader
constructor
A new instance of FactLoader.
- #load(user_query, options) ⇒ Object
- #load_custom_fact(options, fact_name) ⇒ Object
- #load_custom_facts(options) ⇒ Object
- #load_external_facts(options) ⇒ Object
- #load_internal_facts(user_query, options) ⇒ Object
Constructor Details
#initialize ⇒ FactLoader
Returns a new instance of FactLoader.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 9 def initialize @log = Log.new(self) @internal_facts = [] @external_facts = [] @custom_facts = [] @facts = [] @internal_loader ||= InternalFactLoader.new @external_fact_loader ||= ExternalFactLoader.new end |
Instance Attribute Details
#external_facts ⇒ Object (readonly)
Returns the value of attribute external_facts.
7 8 9 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 7 def external_facts @external_facts end |
#facts ⇒ Object (readonly)
Returns the value of attribute facts.
7 8 9 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 7 def facts @facts end |
#internal_facts ⇒ Object (readonly)
Returns the value of attribute internal_facts.
7 8 9 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 7 def internal_facts @internal_facts end |
Instance Method Details
#load(user_query, options) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 21 def load(user_query, ) @internal_facts = load_internal_facts(user_query, ) @custom_facts = load_custom_facts() @external_facts = load_external_facts() filter_env_facts @facts = @internal_facts + @external_facts + @custom_facts end |
#load_custom_fact(options, fact_name) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 45 def load_custom_fact(, fact_name) return [] unless [:custom_facts] custom_facts = @external_fact_loader.load_fact(fact_name) block_facts(custom_facts, ) end |
#load_custom_facts(options) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 52 def load_custom_facts() return [] unless [:custom_facts] @log.debug('Loading custom facts') custom_facts = @external_fact_loader.custom_facts block_facts(custom_facts, ) end |
#load_external_facts(options) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 60 def load_external_facts() return [] unless [:external_facts] @log.debug('Loading external facts') external_facts = @external_fact_loader.external_facts block_facts(external_facts, ) end |
#load_internal_facts(user_query, options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/facter/framework/core/fact_loaders/fact_loader.rb', line 31 def load_internal_facts(user_query, ) internal_facts = [] if user_query || [:show_legacy] # if we have a user query, then we must search in core facts and legacy facts @log.debug('Loading all internal facts') internal_facts = @internal_loader.facts else @log.debug('Load only core facts') internal_facts = @internal_loader.core_facts end block_facts(internal_facts, ) end |