Class: Chimp::Task
- Inherits:
-
Object
- Object
- Chimp::Task
- Defined in:
- lib/right_chimp/resources/task.rb
Overview
This class allows to check on the status of any of the tasks created.
Instance Attribute Summary collapse
-
#tasker ⇒ Object
Returns the value of attribute tasker.
Instance Method Summary collapse
- #details ⇒ Object
- #friendly_url ⇒ Object
- #href ⇒ Object
- #state ⇒ Object
- #wait_for_completed(timeout = 900) ⇒ Object
- #wait_for_state(desired_state, timeout = 900) ⇒ Object
Instance Attribute Details
#tasker ⇒ Object
Returns the value of attribute tasker.
10 11 12 |
# File 'lib/right_chimp/resources/task.rb', line 10 def tasker @tasker end |
Instance Method Details
#details ⇒ Object
48 49 50 |
# File 'lib/right_chimp/resources/task.rb', line 48 def details tasker.show(view: 'extended').detail end |
#friendly_url ⇒ Object
41 42 43 44 45 46 |
# File 'lib/right_chimp/resources/task.rb', line 41 def friendly_url friendly_url = Connection.audit_url + '/audit_entries/' friendly_url += href.split(/\//).last friendly_url = friendly_url.gsub('ae-', '') friendly_url end |
#href ⇒ Object
37 38 39 |
# File 'lib/right_chimp/resources/task.rb', line 37 def href tasker.href end |
#state ⇒ Object
33 34 35 |
# File 'lib/right_chimp/resources/task.rb', line 33 def state tasker.show.summary end |
#wait_for_completed(timeout = 900) ⇒ Object
29 30 31 |
# File 'lib/right_chimp/resources/task.rb', line 29 def wait_for_completed(timeout = 900) wait_for_state('completed', timeout) end |
#wait_for_state(desired_state, timeout = 900) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/right_chimp/resources/task.rb', line 12 def wait_for_state(desired_state, timeout = 900) while timeout > 0 # Make compatible with RL10. status = state.downcase return true if status.match(desired_state) friendly_url = Connection.audit_url + '/audit_entries/' friendly_url += href.split(/\//).last friendly_url = friendly_url.gsub('ae-', '') if status.match('failed') || status.match('aborted') raise "FATAL error, #{status}\n\n Audit: #{friendly_url}\n " end sleep 30 timeout -= 30 end raise "FATAL: Timeout waiting for Executable to complete. State was #{status}" if timeout <= 0 end |