Sha256: e123c724a59eb530fac5ef8eee99058e1625bcb0c460e659d446fab00c9a7fc0
Contents?: true
Size: 943 Bytes
Versions: 47
Compression:
Stored size: 943 Bytes
Contents
# frozen_string_literal: true require 'psych' module PsychK8sCompatibility def self.massage_node(n) if n.is_a?(Psych::Nodes::Scalar) && (n.style == Psych::Nodes::Scalar::PLAIN) && n.value.is_a?(String) && n.value =~ /\A[+-]?\d+(?:\.\d+)?[eE][+-]?\d+\z/ n.style = Psych::Nodes::Scalar::DOUBLE_QUOTED end end refine Psych.singleton_class do def dump(o, io = nil, options = {}) if io.is_a?(Hash) options = io io = nil end visitor = Psych::Visitors::YAMLTree.create(options) visitor << o visitor.tree.each { |n| PsychK8sCompatibility.massage_node(n) } visitor.tree.yaml(io, options) end def dump_stream(*objects) visitor = Psych::Visitors::YAMLTree.create({}) objects.each do |o| visitor << o end visitor.tree.each { |n| PsychK8sCompatibility.massage_node(n) } visitor.tree.yaml end end end
Version data entries
47 entries across 47 versions & 1 rubygems