Class: Gat::Condition
- Inherits:
-
Object
- Object
- Gat::Condition
- Includes:
- Checks, Interpreter
- Defined in:
- lib/gat/condition.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#onfail ⇒ Object
readonly
Returns the value of attribute onfail.
-
#onfail_message ⇒ Object
readonly
Returns the value of attribute onfail_message.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #evalue ⇒ Object
-
#initialize(name, config, operation) ⇒ Condition
constructor
A new instance of Condition.
Methods included from Interpreter
#interpreter_parameter, #interpreter_parameters, #interpreter_shell_command
Methods included from Checks
#check_enough_space, #check_false, #check_file_exists, #check_file_not_exists, #check_i_am_running, #check_true, #exit_if_i_am_running, #need_arguments
Constructor Details
#initialize(name, config, operation) ⇒ Condition
Returns a new instance of Condition.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gat/condition.rb', line 39 def initialize(name, config, operation) operation.gatget.logger.log("trace", "condition", "Initialize condition #{ name }") @operation = operation @config = config @name = name @description = config['description'] || "Another Condition" @type = config['type'] || 'check_true' @onfail = config['onfail'] || 'abort' @onfail_message = config['onfail_message'] || "Gatget Process fail at condition #{ self.name }" end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
31 32 33 |
# File 'lib/gat/condition.rb', line 31 def config @config end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
34 35 36 |
# File 'lib/gat/condition.rb', line 34 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/gat/condition.rb', line 32 def name @name end |
#onfail ⇒ Object (readonly)
Returns the value of attribute onfail.
36 37 38 |
# File 'lib/gat/condition.rb', line 36 def onfail @onfail end |
#onfail_message ⇒ Object (readonly)
Returns the value of attribute onfail_message.
37 38 39 |
# File 'lib/gat/condition.rb', line 37 def @onfail_message end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
30 31 32 |
# File 'lib/gat/condition.rb', line 30 def operation @operation end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
33 34 35 |
# File 'lib/gat/condition.rb', line 33 def type @type end |
Instance Method Details
#evalue ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/gat/condition.rb', line 54 def evalue unless Gat::Checks.instance_methods.include?(self.type) raise GatgetConfigException.new("Check condition method #{ self.type } not available at Gat::Checks", "evalue_condition") end condition_arguments = {} self.config['arguments'].each_pair do |argument_name, argument_parameter| condition_arguments[argument_name] = interpreter_parameter(argument_parameter, self.operation.gatget) end # Eval condition by send check_method # if condition fail, onfail config will checked. unless it is different for 'abort' (default value) # gat will stop the process thourgh GatgetProcessException unless self.send(self.type, condition_arguments) @@conditions_status = 'failed' self.operation.gatget.logger.log('warning', 'condition_eval', "Condition #{ self.name } evalued at False") if self.onfail == 'abort' self.operation.gatget.logger.log('error', 'condition_eval', "Condition #{ self.name } abort Gatget") self.operation.status = 'failed' raise GatgetProcessException.new(self., "evalue_condition") end end end |