Class: NagiosHerald::MessageLoader
- Inherits:
-
Object
- Object
- NagiosHerald::MessageLoader
- Includes:
- Logging
- Defined in:
- lib/nagios-herald/message_loader.rb
Instance Attribute Summary collapse
-
#message_path ⇒ Object
Returns the value of attribute message_path.
Instance Method Summary collapse
-
#enum_message_class_files(message_path) ⇒ Object
Public: Enumerate the available message class files.
-
#initialize ⇒ MessageLoader
constructor
A new instance of MessageLoader.
-
#load_messages ⇒ Object
Public: Load the messages into the namespace.
-
#message_class_files ⇒ Object
Public: Return an array of class files’ paths.
Methods included from Logging
#configure_logger_for, #logger, #logger_for
Constructor Details
#initialize ⇒ MessageLoader
Returns a new instance of MessageLoader.
8 9 10 11 |
# File 'lib/nagios-herald/message_loader.rb', line 8 def initialize # TODO: add support for @options.message_path @message_path = File.("messages", File.dirname(__FILE__)) end |
Instance Attribute Details
#message_path ⇒ Object
Returns the value of attribute message_path.
6 7 8 |
# File 'lib/nagios-herald/message_loader.rb', line 6 def @message_path end |
Instance Method Details
#enum_message_class_files(message_path) ⇒ Object
Public: Enumerate the available message class files.
Returns an array of the class files’ absolute paths
16 17 18 |
# File 'lib/nagios-herald/message_loader.rb', line 16 def () = Dir.glob(File.("*.rb", )) end |
#load_messages ⇒ Object
Public: Load the messages into the namespace. A message can then easily be instantiated later.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nagios-herald/message_loader.rb', line 27 def if .empty? logger.fatal "#{$0}: No messages were found in '#{@message_path}'" exit 1 else .each do || Kernel.load end end end |
#message_class_files ⇒ Object
Public: Return an array of class files’ paths.
21 22 23 |
# File 'lib/nagios-herald/message_loader.rb', line 21 def @message_class_files ||= (@message_path) end |