Sha256: be7d794eddd52420ff2fb70efc0e808b0c45aaefff76694ff9718d6c4dd7838a
Contents?: true
Size: 803 Bytes
Versions: 3
Compression:
Stored size: 803 Bytes
Contents
# frozen_string_literal: true require "erb" require "forwardable" require_relative "value_parser" module Eye::Patch class Settings extend Forwardable def_delegators :parsed, :[], :fetch def initialize(filename) file = File.new(filename) erb = ERB.new(file.read) erb.filename = file.path @settings = YAML.safe_load(erb.result) ensure file&.close end private def parsed @parsed ||= parse(@settings) end def parse(item) case item when Hash item.each_with_object({}) do |(key, val), result| result[key.to_sym] = parse(val) end when Array item.map { |val| parse(val) } when String ValueParser.parse(item) else item end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eye-patch-1.1.0 | lib/eye/patch/settings.rb |
eye-patch-1.0.1 | lib/eye/patch/settings.rb |
eye-patch-1.0.0 | lib/eye/patch/settings.rb |