Sha256: 4e2fc898be749b4d71281a8de4a783c9edd3b5e4ca3f0d35391d060ba4af7107

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 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 deep dup it.
        build = Marshal.load(Marshal.dump(@build))
        @api.update_build(build)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildbox-0.3.1 lib/buildbox/monitor.rb