module StockCruncher::Config
this is a module to load configuration file and environment variable
Public Instance Methods
load(file)
click to toggle source
Load config file and override with env variables
# File lib/stockcruncher/config.rb, line 12 def load(file) config = YAML.load_file(file) overload_alphavantage(config) overload_influxdb(config) end
overload(config, prefix, component, items)
click to toggle source
# File lib/stockcruncher/config.rb, line 18 def overload(config, prefix, component, items) items.each do |key| var = "#{prefix}#{key.upcase}" config[component][key] = ENV[var] unless ENV[var].nil? end config end
overload_alphavantage(config)
click to toggle source
# File lib/stockcruncher/config.rb, line 26 def overload_alphavantage(config) prefix = 'SCR_AV_' component = 'AlphaVantage' items = %w[apikey] overload(config, prefix, component, items) end
overload_influxdb(config)
click to toggle source
# File lib/stockcruncher/config.rb, line 33 def overload_influxdb(config) prefix = 'SCR_IDB_' component = 'InfluxDB' items = %w[scheme host port user password dbname] overload(config, prefix, component, items) end