lib/eventhub/configuration.rb
def load!(args = {})
      # for better rspec testing
      @config_file = args[:config_file] if args[:config_file]
      @environment = args[:environment] if args[:environment]

      new_data = {}
      begin
        new_data = JSON.parse(File.read(@config_file), symbolize_names: true)
      rescue => e
        EventHub.logger.warn("Exception while loading configuration file: #{e}")
        EventHub.logger.info('Using default configuration values')
      end

      deep_merge!(@config_data, default_configuration)
      new_data = new_data[@environment.to_sym]
      deep_merge!(@config_data, new_data)
    end
def load!(args = {})
      # for better rspec testing
      @config_file = args[:config_file] if args[:config_file]
      @environment = args[:environment] if args[:environment]

      new_data = {}
      begin
        new_data = JSON.parse(File.read(@config_file), symbolize_names: true)
      rescue => e
        EventHub.logger.warn("Exception while loading configuration file: #{e}")
        EventHub.logger.info('Using default configuration values')
      end

      deep_merge!(@config_data, default_configuration)
      new_data = new_data[@environment.to_sym]
      deep_merge!(@config_data, new_data)
    end
def load! ( args = { } ) # for better rspec testing @config_file = args [ :config_file ] if args [ :config_file ] @environment = args [ :environment ] if args [ :environment ] new_data = { } begin new_data = JSON . parse ( File . read ( @config_file ) , symbolize_names : true ) rescue => e EventHub . logger . warn ( "Exception while loading configuration file: #{e}" ) EventHub . logger . info ( 'Using default configuration values' ) end deep_merge! ( @config_data , default_configuration ) new_data = new_data [ @environment . to_sym ] deep_merge! ( @config_data , new_data ) end
load configuration from file
load configuration from file