Sha256: 792e204ac43d50144b2bca329ead34d4869b1a5a330e928dd8026e583587f6c7

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

module Buildbox
  class Queue
    def process
      if scheduled = api.builds.payload.first
        start Build.new(scheduled)
      end
    end

    private

    def start(build)
      api.update_build_state(build.uuid, 'started')

      build.start do |result|
        json         = result.as_json
        json[:state] = json.delete(:finished) ? 'finished' : 'started'

        api.update_build_result_async(build.uuid, json.delete(:uuid), json)
      end

      api.update_build_state_async(build.uuid, 'finished')
    end

    def api
      @api ||= Buildbox::API.new(:api_key => Buildbox.configuration.api_key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildbox-0.0.3 lib/buildbox/queue.rb