Sha256: 7956c804bd86c8ad96c797806c4b22a3da996d2b38d6b017c4d5eccc3238ad04

Contents?: true

Size: 661 Bytes

Versions: 6

Compression:

Stored size: 661 Bytes

Contents

require 'rubygems'
require 'celluloid'

module Buildbox
  class Monitor
    include Celluloid

    def initialize(build, api)
      @build = build
      @api   = api
    end

    def monitor
      loop do
        # There is an edge case where the build finishes between making the
        # update_build http call, and breaking. So to make sure we're using the
        # same build object throughout this call, we can just dup it.
        build = @build.dup
        @api.update_build(build) if build.started?

        if build.finished?
          break
        else
          sleep 3 # 3 seconds seems reasonable for now
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
buildbox-0.3 lib/buildbox/monitor.rb
buildbox-0.2.3 lib/buildbox/monitor.rb
buildbox-0.2.2 lib/buildbox/monitor.rb
buildbox-0.2.1 lib/buildbox/monitor.rb
buildbox-0.2 lib/buildbox/monitor.rb
buildbox-0.1.4 lib/buildbox/monitor.rb