Sha256: 03815b7c6bdb4a31c93b5dee254237de5044026e397a6fbd479548ff3cf822b7
Contents?: true
Size: 919 Bytes
Versions: 2
Compression:
Stored size: 919 Bytes
Contents
module WhoAmI module Function class LoadConfig include ProcParty def initialize(root) @root = root end def call hash = YAML.load_file(config_path) deep_symbolize_hash(hash) end private def config_path @config_path ||= if File.exist?(dotfile_path) dotfile_path elsif File.exist?(initializer_path) initializer_path else raise WhoAmI::Error, "Configuration not found" end end def dotfile_path File.join(@root, ".who_am_i.yml") end def initializer_path File.join(@root, "config", "initializers", "who_am_i.yml") end def deep_symbolize_hash(obj) if obj.is_a?(Hash) obj.map { |k, v| [k.to_sym, deep_symbolize_hash(v)] }.to_h else obj end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
who_am_i-0.0.2 | lib/who_am_i/function/load_config.rb |
who_am_i-0.0.1 | lib/who_am_i/function/load_config.rb |