class WerckerAPI::PipelineRunner

Attributes

client[RW]
current_attempt[RW]
delay[RW]
max_attempts[RW]

Public Class Methods

new(client, max_attempts: 20, delay: 10) click to toggle source
# File lib/wercker_api/pipeline_runner.rb, line 27
def initialize(client, max_attempts: 20, delay: 10)
  self.client          = client
  self.max_attempts     = max_attempts
  self.delay           = delay
  self.current_attempt = 0
end

Public Instance Methods

run(pipeline_id, trigger_run_params = {}) click to toggle source
# File lib/wercker_api/pipeline_runner.rb, line 34
def run(pipeline_id, trigger_run_params = {})
  run = client.trigger_run pipeline_id, trigger_run_params

  while %w[running notstarted].include?(run.status)
    raise Timeout.new(pipeline_id, self) if max_attempt_reached?
    sleep @delay
    run = client.run(run.id)
    STDOUT.puts run.status
    puts run.status
    @current_attempt += 1
  end

  run
end

Private Instance Methods

max_attempt_reached?() click to toggle source
# File lib/wercker_api/pipeline_runner.rb, line 52
def max_attempt_reached?
  current_attempt >= max_attempts
end