lib/troy/meta.rb in troy-0.0.35 vs lib/troy/meta.rb in troy-0.0.36

- old
+ new

@@ -1,11 +1,13 @@ +# frozen_string_literal: true + module Troy class Meta extend Forwardable def_delegators :data, :[], :fetch, :key? - REGEX = /^---\n(.*?)\n---\n+/m + REGEX = /^---\n(.*?)\n---\n+/m.freeze attr_reader :file def initialize(file) @file = file @@ -14,17 +16,18 @@ def content @content ||= raw.gsub(REGEX, "") end def data - @data ||= (raw =~ REGEX ? YAML.load(raw[REGEX, 1]) : {}) + @data ||= + raw =~ REGEX ? YAML.safe_load(raw[REGEX, 1], [Date, Time]) : {} end - def method_missing(name, *args, &block) + def method_missing(name, *_args) data[name.to_s] end - def respond_to_missing?(method, include_private = false) + def respond_to_missing?(_method, _include_private = false) true end def raw @raw ||= File.read(file)