Class: Buildbox::Monitor
- Inherits:
-
Object
- Object
- Buildbox::Monitor
- Includes:
- Celluloid
- Defined in:
- lib/buildbox/monitor.rb
Instance Method Summary collapse
-
#initialize(build, api) ⇒ Monitor
constructor
A new instance of Monitor.
- #monitor ⇒ Object
Constructor Details
#initialize(build, api) ⇒ Monitor
Returns a new instance of Monitor.
8 9 10 11 |
# File 'lib/buildbox/monitor.rb', line 8 def initialize(build, api) @build = build @api = api end |
Instance Method Details
#monitor ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/buildbox/monitor.rb', line 13 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.started? || build.finished? if build.finished? break else sleep 3 # 3 seconds seems reasonable for now end end end |