Sha256: 519538bf104e75f2a77e7f43d29cbf670f8996a006472b6b400516e92a698921

Contents?: true

Size: 727 Bytes

Versions: 2

Compression:

Stored size: 727 Bytes

Contents

module Buildbox
  class Worker
    def initialize(access_token)
      @access_token = access_token
    end

    def start
      loop do
        projects.each do |project|
          running_builds = api.scheduled_builds(project).map do |build|
            Monitor.new(build, api).async.monitor
            Runner.new(build).future(:start)
          end

          # wait for all the running builds to finish
          running_builds.map(&:value)

          sleep 5
        end
      end
    end

    private

    def api
      @api ||= Buildbox::API.new
    end

    def projects
      api.worker(:access_token => @access_token, :hostname => hostname).projects
    end

    def hostname
      `hostname`.chomp
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
buildbox-0.1.1 lib/buildbox/worker.rb
buildbox-0.1 lib/buildbox/worker.rb