Class: TelegramMeetupBot::Initializers::Base
- Inherits:
-
Object
- Object
- TelegramMeetupBot::Initializers::Base
show all
- Defined in:
- lib/telegram_meetup_bot/initializers/base.rb
Class Method Summary
collapse
Class Method Details
.exit_if_file_not_exist(file) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/telegram_meetup_bot/initializers/base.rb', line 18
def exit_if_file_not_exist(file)
unless File.exist? file
puts "Error: file not found #{file}"
exit
end
end
|
.preload(config_path) ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/telegram_meetup_bot/initializers/base.rb', line 7
def preload(config_path)
@configurations ||= begin
file = File.join(config_path, self::FILE_NAME)
exit_if_file_not_exist(file)
config = YAML.load(File.open(file).read)
validate(config.keys, file)
config.map { |_,v| v.freeze }
config
end
end
|
.validate(keys, file) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/telegram_meetup_bot/initializers/base.rb', line 25
def validate(keys, file)
missing_keys = self::AVAILABLE_KEYS - keys
if missing_keys.any?
puts "Error: missing params in #{file}\n#{missing_keys.join(', ')}"
exit
end
end
|