Sha256: 1e4a391dc806f2c92eb260d771ca04eb503cb695dd702abe2a82ba2785b1523c

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 KB

Contents

#
# Extra classes needed to operate with Chimp
#
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)
        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

    def wait_for_completed(timeout=900)
      wait_for_state('completed', timeout)
    end

    def state
      self.tasker.show.summary
    end

    def href
      self.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
    end

    def details
      self.tasker.show(:view => "extended").detail
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
right_chimp-2.1.25.2 lib/right_chimp/resources/Task.rb
right_chimp-2.1.25 lib/right_chimp/resources/Task.rb
right_chimp-2.1.24 lib/right_chimp/resources/Task.rb
right_chimp-2.1.22.2 lib/right_chimp/resources/Task.rb
right_chimp-2.1.22.1 lib/right_chimp/resources/Task.rb
right_chimp-2.1.22 lib/right_chimp/resources/Task.rb
right_chimp-2.1.21 lib/right_chimp/resources/Task.rb
right_chimp-2.1.19.1 lib/right_chimp/resources/Task.rb
right_chimp-2.1.19 lib/right_chimp/resources/Task.rb
right_chimp-2.1.18 lib/right_chimp/resources/Task.rb
right_chimp-2.1.17 lib/right_chimp/resources/Task.rb
right_chimp-2.1.15 lib/right_chimp/resources/Task.rb