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
- #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.
11 12 13 |
# File 'lib/right_chimp/resources/Task.rb', line 11 def tasker @tasker end |
Instance Method Details
#details ⇒ Object
39 40 41 |
# File 'lib/right_chimp/resources/Task.rb', line 39 def details self.tasker.show(:view => "extended").detail end |
#href ⇒ Object
35 36 37 |
# File 'lib/right_chimp/resources/Task.rb', line 35 def href self.tasker.href end |
#state ⇒ Object
31 32 33 |
# File 'lib/right_chimp/resources/Task.rb', line 31 def state self.tasker.show.summary end |
#wait_for_completed(timeout = 900) ⇒ Object
27 28 29 |
# File 'lib/right_chimp/resources/Task.rb', line 27 def wait_for_completed(timeout=900) wait_for_state("completed", timeout) end |
#wait_for_state(desired_state, timeout = 900) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/right_chimp/resources/Task.rb', line 13 def wait_for_state(desired_state, timeout=900) while(timeout > 0) state=self.tasker.show.summary return true if self.state.match(desired_state) friendly_url = Connection.audit_url+"/audit_entries/" friendly_url += self.href.split(/\//).last friendly_url = friendly_url.gsub("ae-","") raise "FATAL error, #{self.tasker.show.summary}\n\n Audit: #{friendly_url}'\n " if self.state.match("failed") sleep 30 timeout -= 30 end raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end |