Sha256: a674e4026740546d08dc099df1c45a7b85d85b48bfcb07ec47e0a27adb1c9e29
Contents?: true
Size: 782 Bytes
Versions: 5
Compression:
Stored size: 782 Bytes
Contents
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.load(erb.result) ensure file.close unless file.nil? 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
5 entries across 5 versions & 1 rubygems