lib/facter.rb
def resolve_fact(user_query)
      user_query = user_query.to_s
      resolved_facts = Facter::FactManager.instance.resolve_facts([user_query])
      SessionCache.invalidate_all_caches
      # we must make a distinction between custom facts that return nil and nil facts
      # Nil facts should not be packaged as ResolvedFacts! (add_fact_to_searched_facts packages facts)
      resolved_facts = resolved_facts.reject { |fact| fact.type == :nil }
      fact_collection = FactCollection.new.build_fact_collection!(resolved_facts)
      splitted_user_query = Facter::Utils.split_user_query(user_query)

      begin
        value = fact_collection.value(*splitted_user_query)
        add_fact_to_searched_facts(user_query, value)
      rescue KeyError
        nil
      end
    end
# Returns a ResolvedFact and saves the result in @already_searched array that is used as a global collection.
# @param user_query [String] Fact that needs resolution
#
# @return [ResolvedFact]
Returns a ResolvedFact and saves the result in @already_searched array that is used as a global collection.
Returns a ResolvedFact and saves the result in @already_searched array that is used as a global collection .
def resolve_fact(user_query)
      user_query = user_query.to_s
      resolved_facts = Facter::FactManager.instance.resolve_facts([user_query])
      SessionCache.invalidate_all_caches
      resolved_facts = resolved_facts.reject { |fact| fact.type == :nil }
      fact_collection = FactCollection.new.build_fact_collection!(resolved_facts)
      splitted_user_query = Facter::Utils.split_user_query(user_query)
      begin
        value = fact_collection.value(*splitted_user_query)
        add_fact_to_searched_facts(user_query, value)
      rescue KeyError
        nil
      end
    end
def resolve_fact ( user_query ) user_query = user_query . to_s resolved_facts = Facter :: FactManager . instance . resolve_facts ( [ user_query ] ) SessionCache . invalidate_all_caches resolved_facts = resolved_facts . reject { | fact | fact . type == :nil } fact_collection = FactCollection . new . build_fact_collection! ( resolved_facts ) splitted_user_query = Facter :: Utils . split_user_query ( user_query ) begin value = fact_collection . value ( * splitted_user_query ) add_fact_to_searched_facts ( user_query , value ) rescue KeyError nil end end
Returns a ResolvedFact and saves the result in @already_searched array that is used as a global collection.
Returns a ResolvedFact and saves the result in @already_searched array that is used as a global collection .
# we must make a distinction between custom facts that return nil and nil facts # Nil facts should not be packaged as ResolvedFacts! (add_fact_to_searched_facts packages facts)
None
ResolvedFact
user_query
Fact that needs resolution
Fact that needs resolution