Class: DopCommon::Command
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from HashParser
deep_symbolize_keys, hash_of_pattern_lists_valid?, is_valid_regexp?, key_aliases, load_content, load_content_valid?, parse_hash_of_pattern_lists, parse_pattern_list, pattern_list_valid?, represents_regexp?, symbolize_keys
Methods included from Validator
#log_validation_method, #set_not_valid, #try_validate_obj, #valid?
Constructor Details
#initialize(hash) ⇒ Command
Returns a new instance of Command.
12
13
14
15
16
17
18
|
# File 'lib/dop_common/command.rb', line 12
def initialize(hash)
@hash = symbolize_keys(hash)
@defaults = {
:plugin_timeout => 300,
:verify_after_run => false,
}
end
|
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
10
11
12
|
# File 'lib/dop_common/command.rb', line 10
def hash
@hash
end
|
Instance Method Details
#extended_validator=(obj) ⇒ Object
Add the plugin specific validator
36
37
38
|
# File 'lib/dop_common/command.rb', line 36
def extended_validator=(obj)
@extended_validator = obj if obj.respond_to?(:validate)
end
|
#overwrite_defaults=(defaults_hash) ⇒ Object
31
32
33
|
# File 'lib/dop_common/command.rb', line 31
def overwrite_defaults=(defaults_hash)
@defaults.merge!(defaults_hash)
end
|
#plugin ⇒ Object
40
41
42
|
# File 'lib/dop_common/command.rb', line 40
def plugin
@plugin ||= plugin_valid? ? parse_plugin : nil
end
|
#plugin_timeout ⇒ Object
48
49
50
|
# File 'lib/dop_common/command.rb', line 48
def plugin_timeout
@plugin_timeout = plugin_timeout_valid? ? @hash[:plugin_timeout] : @defaults[:plugin_timeout]
end
|
#title ⇒ Object
44
45
46
|
# File 'lib/dop_common/command.rb', line 44
def title
@title ||= title_valid? ? @hash[:title] : plugin
end
|
#validate ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/dop_common/command.rb', line 20
def validate
log_validation_method('plugin_valid?')
log_validation_method('verify_after_run_valid?')
if @hash.kind_of?(Hash)
log_validation_method('plugin_timeout_valid?')
log_validation_method('verify_commands_valid?')
r_plugin = @plugin || 'unknown' try_validate_obj("Command #{r_plugin}: Can't validate the verify_commands part because of a previous error"){verify_commands}
end
end
|
#verify_after_run ⇒ Object
56
57
58
|
# File 'lib/dop_common/command.rb', line 56
def verify_after_run
@verify_after_run = verify_after_run_valid? ? @hash[:verify_after_run] : @defaults[:verify_after_run]
end
|
#verify_commands ⇒ Object
52
53
54
|
# File 'lib/dop_common/command.rb', line 52
def verify_commands
@verify_commands ||= verify_commands_valid? ? create_verify_commands : []
end
|