Sha256: 9ab1250bf7493de0659b2d2f2a155ff23f1dc1059fbf5020fd3d7526a5dd0551

Contents?: true

Size: 647 Bytes

Versions: 2

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] whitelist_classes
      # Classes that may be parsed by #call.
      attr_reader :whitelist_classes

      def initialize(whitelist_classes: [])
        @whitelist_classes = whitelist_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, whitelist_classes)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
front_matter_parser-0.2.1 lib/front_matter_parser/loader/yaml.rb
front_matter_parser-0.2.0 lib/front_matter_parser/loader/yaml.rb