From b0b92420522edeffa7d8ea58304448f89d772032 Mon Sep 17 00:00:00 2001 From: "Paul Buetow (uranus)" Date: Sun, 18 Oct 2015 10:39:17 +0100 Subject: refactor --- rubyfy.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rubyfy.rb b/rubyfy.rb index a2aa3ce..81f12a0 100755 --- a/rubyfy.rb +++ b/rubyfy.rb @@ -22,24 +22,25 @@ class Rubyfy @conf["verbose"] = true if @conf["debug"] # Read first config found - ["#{ENV["HOME"]}/.rubyfy.json", "rubyfy.json"].each do |config_path| - if File.exists?(config_path) - log(:VERBOSE, "Reading #{config_path}") - config_json = JSON.parse(File.read(config_path)) - log(:VERBOSE, config_json) - config_json.each do |opt, arg| + ["#{ENV["HOME"]}/.rubyfy.json", "rubyfy.json"].each do |conf_path| + if File.exists?(conf_path) + log(:VERBOSE, "Reading #{conf_path}") + conf_json = JSON.parse(File.read(conf_path)) + log(:VERBOSE, conf_json) + conf_json.each do |opt, arg| @conf[opt] = arg unless @conf[arg] end break end end + # Needed a 2nd time (as we read the config file) + @conf["verbose"] = true if @conf["debug"] + # Set defaults of values if not set @conf["parallel"] = 1 unless @conf["parallel"] @conf["user"] = ENV["USER"] unless @conf["user"] @conf["outdir"] = "./results" unless @conf["outdir"] - # Needed a 2nd time (as we read the config file) - @conf["verbose"] = true if @conf["debug"] log(:DEBUG, @conf) end -- cgit v1.2.3