Class: Gat::Operation
- Inherits:
-
Object
- Object
- Gat::Operation
- Defined in:
- lib/gat/operation.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#folders ⇒ Object
readonly
Returns the value of attribute folders.
-
#gatget ⇒ Object
readonly
Returns the value of attribute gatget.
-
#helpers ⇒ Object
readonly
Returns the value of attribute helpers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#programs ⇒ Object
readonly
Returns the value of attribute programs.
-
#status ⇒ Object
Returns the value of attribute status.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #evalue_dependences(dependence_type) ⇒ Object
-
#execute ⇒ Object
Execute operation.
- #get_action(action_name) ⇒ Object
-
#initialize(operation_name, operation_config, gatget) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(operation_name, operation_config, gatget) ⇒ Operation
Returns a new instance of Operation.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gat/operation.rb', line 73 def initialize(operation_name, operation_config, gatget) @name = operation_name @gatget = gatget @description = operation_config['description'] || "#{ operation_name } at GatGet #{ self.class }" @config = operation_config @helpers = operation_config['helpers'] || [] @status = 'ok' if operation_config['users'] and not valid_user(operation_config['users']) raise GatgetException.new('Current user is not allowed to run gatget operation', 'valid_user') end for dependence in [ 'programs', 'arguments', 'folders' ] self.instance_variable_set("@#{ dependence }", evalue_dependences(dependence)) end end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
70 71 72 |
# File 'lib/gat/operation.rb', line 70 def actions @actions end |
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
62 63 64 |
# File 'lib/gat/operation.rb', line 62 def arguments @arguments end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
57 58 59 |
# File 'lib/gat/operation.rb', line 57 def config @config end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
59 60 61 |
# File 'lib/gat/operation.rb', line 59 def description @description end |
#folders ⇒ Object (readonly)
Returns the value of attribute folders.
63 64 65 |
# File 'lib/gat/operation.rb', line 63 def folders @folders end |
#gatget ⇒ Object (readonly)
Returns the value of attribute gatget.
55 56 57 |
# File 'lib/gat/operation.rb', line 55 def gatget @gatget end |
#helpers ⇒ Object (readonly)
Returns the value of attribute helpers.
65 66 67 |
# File 'lib/gat/operation.rb', line 65 def helpers @helpers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
58 59 60 |
# File 'lib/gat/operation.rb', line 58 def name @name end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
67 68 69 |
# File 'lib/gat/operation.rb', line 67 def outputs @outputs end |
#programs ⇒ Object (readonly)
Returns the value of attribute programs.
61 62 63 |
# File 'lib/gat/operation.rb', line 61 def programs @programs end |
#status ⇒ Object
Returns the value of attribute status.
71 72 73 |
# File 'lib/gat/operation.rb', line 71 def status @status end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
68 69 70 |
# File 'lib/gat/operation.rb', line 68 def users @users end |
Instance Method Details
#evalue_dependences(dependence_type) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gat/operation.rb', line 92 def evalue_dependences(dependence_type) # get named dependences dependences = self.config[dependence_type] || [] evalued_dependences = Array.new dependences.each do |dependence| config = self.gatget.get_element_config(dependence_type, dependence) dependence_object = Object.module_eval("Gat::Dependence::#{ dependence_type.gsub(/s$/,'').capitalize }").new(dependence, config, self) dependence_object.evalue evalued_dependences << dependence_object end evalued_dependences end |
#execute ⇒ Object
Execute operation. After set all dependences, operation is ready to run. Just do it By steps, operation will run:
1) Helpers 2) Actions 3) Outputs
Each step, operation will check that state is ok, if not ok, operation is stopped
115 116 117 118 119 120 121 122 123 |
# File 'lib/gat/operation.rb', line 115 def execute run_helpers if continue_operation('helpers') ret = run_actions if continue_operation('actions') self.gatget.logger.log("message", "operation", "Operation #{ self.name } Ended!") run_outputs ret end |
#get_action(action_name) ⇒ Object
126 127 128 129 |
# File 'lib/gat/operation.rb', line 126 def get_action(action_name) actions = self.actions.select { |a| a.name == action_name } actions.first || raise(GatgetException.new("Action #{ action_name } not found at operation #{ self.name }", "get_actions")) end |