Sha256: f4f4f09990efc69a1b65d860469a9db958e63490915ff9f6272ca4968bcd29a4

Contents?: true

Size: 647 Bytes

Versions: 1

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true

require 'yaml'

module FrontMatterParser
  module Loader
    # {Loader} that uses YAML library
    class Yaml
      # @!attribute [r] allowlist_classes
      # Classes that may be parsed by #call.
      attr_reader :allowlist_classes

      def initialize(allowlist_classes: [])
        @allowlist_classes = allowlist_classes
      end

      # Loads a hash front matter from a string
      #
      # @param string [String] front matter string representation
      # @return [Hash] front matter hash representation
      def call(string)
        YAML.safe_load(string, allowlist_classes)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
front_matter_parser-1.0.0 lib/front_matter_parser/loader/yaml.rb