class Travis::Lock::Retry

Constants

WAIT

Public Instance Methods

run() { || ... } click to toggle source
# File lib/travis/lock/support/retry.rb, line 6
def run
  wait until result = yield
  result
end
started() click to toggle source
# File lib/travis/lock/support/retry.rb, line 16
def started
  @started ||= Time.now
end
timeout() click to toggle source
# File lib/travis/lock/support/retry.rb, line 24
def timeout
  options[:timeout] || 30
end
timeout!() click to toggle source
# File lib/travis/lock/support/retry.rb, line 28
def timeout!
  fail Timeout.new(name, options || {})
end
timeout?() click to toggle source
# File lib/travis/lock/support/retry.rb, line 20
def timeout?
  started + timeout < Time.now
end
wait() click to toggle source
# File lib/travis/lock/support/retry.rb, line 11
def wait
  sleep(rand(options[:wait] || WAIT))
  timeout! if timeout?
end