Class: Facter::YamlFactFormatter

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

Instance Method Summary collapse

Constructor Details

#initializeYamlFactFormatter

Returns a new instance of YamlFactFormatter.



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

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

Instance Method Details

#format(fact_hash) ⇒ Object



9
10
11
12
13
14
# File 'lib/framework/formatters/yaml_fact_formatter.rb', line 9

def format(fact_hash)
  yaml_pretty = YAML.dump(JSON.parse(JsonFactFormatter.new.format(fact_hash)))

  @log.debug('Replace ---  from yaml beginning, to keep it compatible with C facter')
  yaml_pretty.gsub(/^---[\r\n]+/, '')
end