lib/right_chimp/resources/task.rb in right_chimp-2.2.1 vs lib/right_chimp/resources/task.rb in right_chimp-2.2.2

- old
+ new

@@ -4,47 +4,49 @@ module Chimp # # This class allows to check on the status of any of the tasks created. # class Task - attr_writer :tasker attr_reader :tasker - def wait_for_state(desired_state, timeout=900) - while(timeout > 0) - state=self.tasker.show.summary - return true if self.state.match(desired_state) + def wait_for_state(desired_state, timeout = 900) + while timeout > 0 + # Make compatible with RL10. + state = tasker.show.summary.downcase + return true if state.match(desired_state) friendly_url = Connection.audit_url + '/audit_entries/' - friendly_url += self.href.split(/\//).last + friendly_url += 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") + if state.match('failed') || state.match('aborted') + raise "FATAL error, #{tasker.show.summary}\n\n Audit: #{friendly_url}\n " + end sleep 30 timeout -= 30 end raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0 end - def wait_for_completed(timeout=900) + def wait_for_completed(timeout = 900) wait_for_state('completed', timeout) end def state - self.tasker.show.summary + tasker.show.summary end def href - self.tasker.href + tasker.href end def friendly_url - friendly_url = Connection.audit_url+"/audit_entries/" - friendly_url += self.href.split(/\//).last - friendly_url = friendly_url.gsub("ae-","") + friendly_url = Connection.audit_url + '/audit_entries/' + friendly_url += href.split(/\//).last + friendly_url = friendly_url.gsub('ae-', '') friendly_url end def details - self.tasker.show(:view => "extended").detail + tasker.show(view: 'extended').detail end end end