Sha256: 45c563fa6b7c5411f9c20536391a2ae5a86d965065002fa56d3bea96eff1229a

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

require 'broker/payload'

module Broker
  class Queue
    
    attr_reader :processed, :pending, :failed
    
    def initialize
      @processed = 0
      @pending = []
      @failed = []
    end
    
    def push(paths)
      paths.each { |p| @pending << Broker::Payload.parse(p) }
    end
    
    def next
      @pending.pop
    end
    
    def empty?
      @pending.empty?
    end
    
    def failure(payload)
      @failed << payload
    end
    
    def success(payload)
      @processed +=1
      move payload
    end
    
    private
    
    def move(payload)
      f = File.basename(payload.pkg.file)
      FileUtils.mv payload.pkg.file, File.join(Broker.options[:processed_path],"/", f)
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
broker-0.1.1 lib/broker/queue.rb