Class: Jabbot::FileConfig
Overview
Deprecated: Configuration from files
Constant Summary
Constants inherited from Config
Instance Attribute Summary
Attributes inherited from Config
Instance Method Summary collapse
-
#initialize(fos = File.expand_path("config/bot.yml")) ⇒ FileConfig
constructor
Public: Initializes a new FileConfig object.
Methods inherited from Config
#add, default, #method_missing, #to_hash
Constructor Details
#initialize(fos = File.expand_path("config/bot.yml")) ⇒ FileConfig
Public: Initializes a new FileConfig object.
fos - Accepts a Stream or a String filename to read configuration from
(default: "./config/bot.yml")
If a stream is passed it is not closed from within the method.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/jabbot/config.rb', line 89 def initialize(fos = File.("config/bot.yml")) warn "Jabbot::FileConfig is deprecated and will be removed in the next version." stream = fos.is_a?(String) ? File.open(fos, "r") : fos begin config = YAML.load(stream.read) config.symbolize_keys! if config rescue Exception => err puts err. puts "Unable to load configuration, aborting" exit ensure stream.close if fos.is_a?(String) end super config.is_a?(Hash) ? config : {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jabbot::Config