Class: Rapidmail::Utils::ConfigLoader
- Inherits:
-
Object
- Object
- Rapidmail::Utils::ConfigLoader
- Defined in:
- lib/rapidmail/utils/config_loader.rb
Overview
Utility class for loading Rapidmail configuration from YAML files
Class Method Summary collapse
-
.load(file_path) ⇒ void
Loads configuration from a YAML file and configures Rapidmail.
Class Method Details
.load(file_path) ⇒ void
This method returns an undefined value.
Loads configuration from a YAML file and configures Rapidmail
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rapidmail/utils/config_loader.rb', line 21 def self.load(file_path) config = YAML.load_file(file_path) raise Rapidmail::Error, "Missing 'username' in configuration file" unless config.key?("username") raise Rapidmail::Error, "Missing 'password' in configuration file" unless config.key?("password") Rapidmail.configure do |c| c.username = config["username"] c.password = config["password"] end puts "Configuration loaded from #{file_path}" rescue Rapidmail::Error => e puts "Warning: Failed to load configuration: #{e.}" end |