Class: Chimp::Task
- Inherits:
-
Object
- Object
- Chimp::Task
- Defined in:
- lib/right_chimp/objects/ChimpObjects.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
- #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.
280 281 282 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 280 def tasker @tasker end |
Instance Method Details
#href ⇒ Object
305 306 307 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 305 def href self.tasker.href end |
#state ⇒ Object
301 302 303 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 301 def state self.tasker.show.summary end |
#wait_for_completed(timeout = 900) ⇒ Object
297 298 299 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 297 def wait_for_completed(timeout=900) wait_for_state("completed", timeout) end |
#wait_for_state(desired_state, timeout = 900) ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/right_chimp/objects/ChimpObjects.rb', line 282 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 = "https://"+Connection.endpoint+"/audit_entries/" friendly_url += self.href.split(/\//).last friendly_url = friendly_url.gsub("ae-","") # raise "FATAL error, #{self.tasker.show.summary}\n See Audit: API:#{self.href}, WWW:<a href='#{friendly_url}'>#{friendly_url}</a>\n " if self.state.match("failed") raise "FATAL error, #{self.tasker.show.summary}\n See 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 |