Sha256: b037faf31a943516a32e94a5cb3498147d40cd6a3a4b88affe8475475f110fc7

Contents?: true

Size: 493 Bytes

Versions: 3

Compression:

Stored size: 493 Bytes

Contents

# frozen_string_literal: true

module Facter
  class YamlFactFormatter
    def initialize
      @log = Log.new(self)
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.20 lib/framework/formatters/yaml_fact_formatter.rb
facter-4.0.19 lib/framework/formatters/yaml_fact_formatter.rb
facter-4.0.18 lib/framework/formatters/yaml_fact_formatter.rb