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.
11 12 13 |
# File 'lib/right_chimp/resources/Task.rb', line 11 def tasker @tasker end |
Instance Method Details
#details ⇒ Object
46 47 48 |
# File 'lib/right_chimp/resources/Task.rb', line 46 def details self.tasker.show(:view => "extended").detail end |
#friendly_url ⇒ Object
39 40 41 42 43 44 |
# File 'lib/right_chimp/resources/Task.rb', line 39 def friendly_url friendly_url = Connection.audit_url+"/audit_entries/" friendly_url += self.href.split(/\//).last friendly_url = friendly_url.gsub("ae-","") friendly_url 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, #{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 |