Sha256: 7f89de3e49f84a1331f673a069f1517f0a222140e1445d989ad1cc1150b320e3
Contents?: true
Size: 765 Bytes
Versions: 10
Compression:
Stored size: 765 Bytes
Contents
require "yaml" module Bisu module Config extend self def parse(file_name) unless file_name Logger.error("Config file not provided") return nil end unless File.exists?(file_name) Logger.error("Could not find config file #{file_name}") return nil end begin deep_sym(YAML::load_file(file_name)) rescue Exception => e Logger.error("Could not parse config file #{file_name}: #{e}") return nil end end private def deep_sym(obj) if obj.is_a?(Array) obj.map { |v| deep_sym(v) } elsif obj.is_a?(Hash) obj.inject({}) { |memo, (k,v)| memo[k.to_sym] = deep_sym(v); memo } else obj end end end end
Version data entries
10 entries across 10 versions & 1 rubygems