Class: Bamboo::Client::Rest::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboo-client/rest.rb

Overview

Change

Instance Method Summary collapse

Constructor Details

#initialize(data, http) ⇒ Queue

Returns a new instance of Queue.



277
278
279
280
# File 'lib/bamboo-client/rest.rb', line 277

def initialize(data, http)
  @data = data
  @http = http
end

Instance Method Details

#add(key) ⇒ Object



286
287
288
289
# File 'lib/bamboo-client/rest.rb', line 286

def add(key)
  data = @http.post(File.join(SERVICE, "queue/#{URI.escape key}"), {}).data
  QueuedBuild.new(data, @http)
end

#queued_buildsObject



291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/bamboo-client/rest.rb', line 291

def queued_builds
  @queued_builds ||= (
    unless @data['queuedBuilds'] && @data['queuedBuilds']['queuedBuild']
      @data = @http.get(File.join(SERVICE, 'queue'), {:expand => 'queuedBuilds'}).data
    end

    begin
      @data.fetch('queuedBuilds').fetch('queuedBuild').map { |e| QueuedBuild.new(e, @http) }
    rescue IndexError
      []
    end
  )
end

#sizeObject



282
283
284
# File 'lib/bamboo-client/rest.rb', line 282

def size
  @data['queuedBuilds']['size']
end