Class: StreamData::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/config.rb

Constant Summary collapse

ALLOWED_SERVICE_TYPES =
["azure","aws"]

Class Method Summary collapse

Class Method Details

.read_configObject



6
7
8
# File 'lib/config.rb', line 6

def self.read_config
	@config = YAML.load_file('lib/stream_config.yml')
end

.validate_configObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/config.rb', line 12

def self.validate_config
	begin
		@config["type_of_service"] || raise(StandardError.new('Specify the servcie type'))
		@config["service_key"] || raise(StandardError.new('Service Key is missing, please specify in config'))
		@config["service_secret"] || raise(StandardError.new('Service Secret is missing, please specify in config'))
		@config["delivery_stream_name"] || raise(StandardError.new('Delivery Stream Name is missing, please specify in config'))
		@config["region"] || raise(StandardError.new('Specify the Region'))
		raise(StandardError.new('This type of servcie is not supported')) unless ALLOWED_SERVICE_TYPES.include?(@config["type_of_service"])
	rescue Exception => e
		raise(StandardError.new("Not a valid config, #{e.message}"))
	end
end