lib/env.rb in markdown_exec-1.3.1 vs lib/env.rb in markdown_exec-1.3.2

- old
+ new

@@ -8,30 +8,34 @@ # :reek:BooleanParameter # :reek:DataClump # :reek:NilCheck # :reek:UtilityFunction def env_bool(name, default: false) - return default if name.nil? || (val = ENV[name]).nil? + return default if name.nil? || (val = ENV.fetch(name, nil)).nil? return false if val.empty? || val == '0' true end + def env_bool_false(name) + !(val = (name && ENV.fetch(name, nil))).nil? && !(val.empty? || val == '0') + end + # skip :reek:DataClump # skip :reek:NilCheck # skip :reek:UtilityFunction def env_int(name, default: 0) - return default if name.nil? || (val = ENV[name]).nil? + return default if name.nil? || (val = ENV.fetch(name, nil)).nil? return default if val.empty? val.to_i end # skip :reek:DataClump # skip :reek:NilCheck # skip :reek:UtilityFunction def env_str(name, default: '') - return default if name.nil? || (val = ENV[name]).nil? + return default if name.nil? || (val = ENV.fetch(name, nil)).nil? val || default end end