Class: Facter::YamlFactFormatter
- Inherits:
-
Object
- Object
- Facter::YamlFactFormatter
- Defined in:
- lib/framework/formatters/yaml_fact_formatter.rb
Instance Method Summary collapse
- #format(fact_hash) ⇒ Object
-
#initialize ⇒ YamlFactFormatter
constructor
A new instance of YamlFactFormatter.
Constructor Details
#initialize ⇒ YamlFactFormatter
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 15 16 |
# 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 single backslash with double backslashes') yaml_pretty.gsub!(/\\/, '\&\&') @log.debug('Replace --- from yaml beginning, to keep it compatible with C facter') yaml_pretty.gsub(/^---[\r\n]+/, '') end |