Sha256: 0aaa2838760eaf773b913a08ca5e12d97df55b05864ac04856273a5aa1c5f80a
Contents?: true
Size: 618 Bytes
Versions: 2
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true module Troy class Meta extend Forwardable def_delegators :data, :[], :fetch, :key? REGEX = /^---\n(.*?)\n---\n+/m.freeze attr_reader :file def initialize(file) @file = file end def content @content ||= raw.gsub(REGEX, "") end def data @data ||= raw =~ REGEX ? YAML.unsafe_load(raw[REGEX, 1]) : {} end def method_missing(name, *_args) data[name.to_s] end def respond_to_missing?(_method, _include_private = false) true end def raw @raw ||= File.read(file) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
troy-0.0.39 | lib/troy/meta.rb |
troy-0.0.38 | lib/troy/meta.rb |