class NumberStation::ConfigReader

Public Class Methods

read_config() click to toggle source
# File lib/number_station/config_reader.rb, line 25
def self.read_config()
  begin
    config_file_path = File.join(Dir.pwd, "conf.json")
    NumberStation.set_data( JSON.parse(File.read(config_file_path)) )
    NumberStation.set_log( Logger.new(STDOUT) )
    NumberStation.log.level = NumberStation.data["logging"]["level"]
    NumberStation.log.debug "Reading in config file: #{config_file_path}"
  rescue Exception => e
    config_file_path = File.join(File.dirname(__FILE__), "../../config/conf.json")
    NumberStation.set_data( JSON.parse(File.read(config_file_path)) )
    NumberStation.set_log( Logger.new(STDOUT) )
    NumberStation.log.level = NumberStation.data["logging"]["level"]
    NumberStation.log.debug "Reading in default config file: #{config_file_path}"
  end
  NumberStation.log.debug "NumberStation::ConfigReader#read_config"
end