Sha256: f76ab6fe9aba5066dbffafc4d0ef131ad261295741bda94c1665df9227f3d19c

Contents?: true

Size: 618 Bytes

Versions: 2

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

require "yaml"

class Array
  def deep_stringify_keys
    each_with_object([]) do |value, accum|
      if value.is_a?(Hash) || value.is_a?(Array)
        new_val = value.deep_stringify_keys
        accum.push new_val
      else
        accum.push value
      end
      accum
    end
  end
end

module Dato
  module Dump
    module Format
      module Yaml
        def self.dump(value)
          YAML.dump(value.deep_stringify_keys).chomp.gsub(/^-+\n/, "")
        end

        def self.frontmatter_dump(value)
          "---\n#{dump(value)}\n---"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dato-0.8.3 lib/dato/dump/format/yaml.rb
dato-0.8.2 lib/dato/dump/format/yaml.rb