Class: Facter::HoconFactFormatter

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

Instance Method Summary collapse

Constructor Details

#initializeHoconFactFormatter

Returns a new instance of HoconFactFormatter.



5
6
7
# File 'lib/facter/framework/formatters/hocon_fact_formatter.rb', line 5

def initialize
  @log = Log.new(self)
end

Instance Method Details

#format(resolved_facts) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/facter/framework/formatters/hocon_fact_formatter.rb', line 9

def format(resolved_facts)
  user_queries = resolved_facts.uniq(&:user_query).map(&:user_query)

  return if user_queries.count < 1
  return format_for_multiple_user_queries(user_queries, resolved_facts) if user_queries.count > 1

  user_query = user_queries.first
  return format_for_no_query(resolved_facts) if user_query.empty?
  return format_for_single_user_query(user_queries.first, resolved_facts) unless user_query.empty?
end