lib/hyla.rb in hyla-1.0.7.pre.8 vs lib/hyla.rb in hyla-1.0.7.pre.9

- old
+ new

@@ -54,23 +54,37 @@ def self.logger @logger ||= Logger.new end def self.logger2 - log_cfg ||= $options[:log] + configs = $options[:config].split(",").map(&:strip) if $options[:config] + if !configs.nil? && !configs.empty? + @yaml_cfg = nil + configs.each do |config| + cfg = safe_load_file(config) + @yaml_cfg = cfg if @yaml_cfg.nil? + @yaml_cfg = @yaml_cfg.deep_merge(cfg) + end + else + # We will try to read the _config.yaml file if it exists within the project + cfg = safe_load_file(Configuration::YAML_CONFIG_FILE_NAME) + @yaml_cfg = cfg if !cfg.nil? && !cfg.empty? + end + hyla_cfg ||= @yaml_cfg if @yaml_cfg - hyla_cfg = safe_load_file($options[:config]) if $options[:config] + log_cfg ||= $options[:log] + mode ||= hyla_cfg['mode'] if hyla_cfg + dirname ||= hyla_cfg['dirname'] if hyla_cfg + logname ||= hyla_cfg['logname'] if hyla_cfg + level ||= hyla_cfg['level'] if hyla_cfg + tracer ||= hyla_cfg['tracer'] if hyla_cfg - mode ||= hyla_cfg['mode'] - dirname ||= hyla_cfg['dirname'] - logname ||= hyla_cfg['logname'] - level ||= hyla_cfg['level'] - tracer ||= hyla_cfg['tracer'] - $logger2 ||= Logger2.new(mode, log_cfg, dirname, logname, level, tracer) end def self.safe_load_file(filename) f = File.expand_path(filename, $cmd_directory) YAML.safe_load_file(f) + rescue SystemCallError + puts "No configuration file retrieved for the name : #{filename}" end end \ No newline at end of file