Method: Facter::QueryParser.parse

Defined in:
lib/facter/framework/parsers/query_parser.rb

.parse(query_list, loaded_facts) ⇒ Array<SearchedFact>

Searches for facts that could resolve a user query. There are 4 types of facts:

root facts
  e.g. networking
child facts
  e.g. networking.dhcp
composite facts
  e.g. networking.interfaces.en0.bindings.address
regex facts (legacy)
  e.g. impaddress_end160

Because a root fact will always be resolved by a collection of child facts, we can return one or more child facts for each parent.

Parameters:

  • query_list (Array)

    The list of facts to search for

  • loaded_facts (Array)

    All of the fact definitions for the current operating system

Returns:

  • (Array<SearchedFact>)

    a list of searchable facts that resolve the user’s query



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/facter/framework/parsers/query_parser.rb', line 25

def parse(query_list, loaded_facts)
  matched_facts = []
  @query_list = query_list

  return no_user_query(loaded_facts) unless query_list.any?

  query_list.each do |query|
    found_facts = search_for_facts(query, loaded_facts)
    matched_facts << found_facts
  end

  matched_facts.flatten(1)
end