Class: DAF::YAMLDataSource
- Inherits:
-
CommandDataSource
- Object
- CommandDataSource
- DAF::YAMLDataSource
- Defined in:
- lib/daf/datasources/yaml_data_source.rb
Overview
A datasource that is parsed out of a YAML file does not permit any dynamic updates, but useful for a basic command parser
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#monitor ⇒ Object
readonly
Returns the value of attribute monitor.
Instance Method Summary collapse
- #action_options ⇒ Object
-
#initialize(file_path) ⇒ YAMLDataSource
constructor
Accepts the path of the YAML file to be parsed into commands - will throw a CommandException should it have invalid parameters.
Constructor Details
#initialize(file_path) ⇒ YAMLDataSource
Accepts the path of the YAML file to be parsed into commands - will throw a CommandException should it have invalid parameters
16 17 18 19 20 21 22 |
# File 'lib/daf/datasources/yaml_data_source.rb', line 16 def initialize(file_path) configuration = YAML.load_file(file_path) @action_class, @monitor_class = action_monitor_classes(configuration) @monitor = @monitor_class.new(configuration['Monitor']['Options']) @action = @action_class.new @action_options = configuration['Action']['Options'] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
9 10 11 |
# File 'lib/daf/datasources/yaml_data_source.rb', line 9 def action @action end |
#monitor ⇒ Object (readonly)
Returns the value of attribute monitor.
9 10 11 |
# File 'lib/daf/datasources/yaml_data_source.rb', line 9 def monitor @monitor end |
Instance Method Details
#action_options ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/daf/datasources/yaml_data_source.rb', line 24 def # Attempt resolution to outputs of monitor return @action_options unless @monitor_class.outputs.length > 0 = @action_options.clone @monitor_class.outputs.each do |output, _type| .each do |option_key, option_value| [option_key] = option_value.gsub("{{#{output}}}", @monitor.send(output).to_s) end end end |