lib/anyway/config.rb in anyway_config-0.5.1.rc1 vs lib/anyway/config.rb in anyway_config-0.5.1

- old
+ new

@@ -1,12 +1,10 @@ -# frozen_string_literal: true - require 'anyway/ext/class' require 'anyway/ext/deep_dup' require 'anyway/ext/hash' -module Anyway # :nodoc: +module Anyway using Anyway::Ext::Class using Anyway::Ext::DeepDup using Anyway::Ext::Hash # Base config class @@ -73,34 +71,25 @@ load_from_file(config) load_from_env(config) end def load_from_file(config) - config_path = Anyway.env.fetch(config_name).delete('conf') || - "./config/#{config_name}.yml" + config_path = (Anyway.env.send(config_name) || {}).delete('conf') if config_path && File.file?(config_path) - config.deep_merge!(parse_yml(config_path) || {}) + require 'yaml' + config.deep_merge!(YAML.load_file(config_path) || {}) end config end def load_from_env(config) - config.deep_merge!(Anyway.env.fetch(config_name)) + config.deep_merge!(Anyway.env.send(config_name) || {}) config end private def set_value(key, val) send("#{key}=", val) if respond_to?(key) - end - - def parse_yml(path) - require 'yaml' - if defined?(ERB) - YAML.safe_load(ERB.new(File.read(path)).result) - else - YAML.load_file(path) - end end end end