Method: Datapimp::Configuration#calculate_config

Defined in:
lib/datapimp/configuration.rb

#calculate_config(using_environment = true) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/datapimp/configuration.rb', line 137

def calculate_config(using_environment = true)
  @current = defaults.merge(home_config.merge(cwd_config.merge(applied_config))).to_mash

  if ENV['DATAPIMP_CONFIG_EXTRA'].to_s.length > 0
    extra_config = Datapimp::Util.load_config_file(ENV['DATAPIMP_CONFIG_EXTRA'])
    @current.merge!(extra_config) if extra_config.is_a?(Hash)
  end

  (defaults.keys + home_config.keys + cwd_config.keys).uniq.each do |key|
    upper = key.to_s.upcase
    if ENV[upper]
      @current[key] = ENV[upper]
    end
  end if using_environment

  @current
end