Sha256: 38ce34949f8cdc2bb89aad6c58f6c4a2ba034d3d504b6d0b3da83229ad2c7186

Contents?: true

Size: 662 Bytes

Versions: 71

Compression:

Stored size: 662 Bytes

Contents

# frozen_string_literal: true
require 'active_support/core_ext/hash/keys'
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

71 entries across 71 versions & 1 rubygems

Version Path
dato-0.6.9 lib/dato/dump/format/yaml.rb
dato-0.6.8 lib/dato/dump/format/yaml.rb
dato-0.6.7 lib/dato/dump/format/yaml.rb
dato-0.6.6 lib/dato/dump/format/yaml.rb
dato-0.6.5 lib/dato/dump/format/yaml.rb
dato-0.6.3 lib/dato/dump/format/yaml.rb
dato-0.6.3.beta lib/dato/dump/format/yaml.rb
dato-0.6.2 lib/dato/dump/format/yaml.rb
dato-0.6.1 lib/dato/dump/format/yaml.rb
dato-0.6.0 lib/dato/dump/format/yaml.rb
dato-0.5.1 lib/dato/dump/format/yaml.rb
dato-0.5.0 lib/dato/dump/format/yaml.rb
dato-0.4.3 lib/dato/dump/format/yaml.rb
dato-0.4.2 lib/dato/dump/format/yaml.rb
dato-0.4.1 lib/dato/dump/format/yaml.rb
dato-0.4.0 lib/dato/dump/format/yaml.rb
dato-0.3.31 lib/dato/dump/format/yaml.rb
dato-0.4.0.pre lib/dato/dump/format/yaml.rb
dato-0.3.30 lib/dato/dump/format/yaml.rb
dato-0.3.29 lib/dato/dump/format/yaml.rb