Class: Facter::FormatterHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/framework/formatters/formatter_helper.rb

Class Method Summary collapse

Class Method Details

.retrieve_fact_collection(resolved_facts) ⇒ Object



19
20
21
22
# File 'lib/facter/framework/formatters/formatter_helper.rb', line 19

def retrieve_fact_collection(resolved_facts)
  fact_collection = FactCollection.new.build_fact_collection!(resolved_facts)
  Facter::Utils.sort_hash_by_key(fact_collection)
end

.retrieve_fact_value_for_single_query(user_query, resolved_facts) ⇒ Object



24
25
26
27
28
29
# File 'lib/facter/framework/formatters/formatter_helper.rb', line 24

def retrieve_fact_value_for_single_query(user_query, resolved_facts)
  fact_collection = build_fact_collection_for_user_query(user_query, resolved_facts)
  fact_collection = Utils.sort_hash_by_key(fact_collection)
  splitted_user_query = Utils.split_user_query(user_query)
  fact_collection.dig(*splitted_user_query)
end

.retrieve_facts_to_display_for_user_query(user_queries, resolved_facts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/facter/framework/formatters/formatter_helper.rb', line 6

def retrieve_facts_to_display_for_user_query(user_queries, resolved_facts)
  facts_to_display = {}
  user_queries.each do |user_query|
    fact_collection = build_fact_collection_for_user_query(user_query, resolved_facts)

    splitted_user_query = Utils.split_user_query(user_query)
    printable_value = fact_collection.dig(*splitted_user_query)
    facts_to_display.merge!(user_query => printable_value)
  end

  Facter::Utils.sort_hash_by_key(facts_to_display)
end