module Pechkin::ConfigurationLoader
Common code for all configuration loaders. To use this code just include module in user class.
Public Instance Methods
check_field(object, field, file)
click to toggle source
# File lib/pechkin/configuration/configuration_loader.rb, line 5 def check_field(object, field, file) contains = object.key?(field) raise ConfigurationError, "#{file}: '#{field}' is missing" unless contains object[field] end
create_connector(bot)
click to toggle source
# File lib/pechkin/configuration/configuration_loader.rb, line 13 def create_connector(bot) case bot.connector when 'tg', 'telegram' Connector::Telegram.new(bot.token, bot.name) when 'slack' Connector::Slack.new(bot.token, bot.name) else raise 'Unknown connector ' + bot.connector + ' for ' + bot.name end end
yaml_load(file)
click to toggle source
# File lib/pechkin/configuration/configuration_loader.rb, line 24 def yaml_load(file) YAML.safe_load(IO.read(file)) end