Sha256: 1a166d5a489a35a82df08f9e63c784b20fb7c5a2ab072aa4fce35530e24d6297

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

require 'yaml'
require 'logger'
require 'forwardable'

require "localjob/version"
require 'localjob/channel'
require 'localjob/worker'

class Localjob
  extend Forwardable

  attr_reader :name
  attr_accessor :queue

  def_delegators :queue, :to_io, :destroy, :size

  def initialize(name = "localjob")
    @name = name
  end

  def serializer
    YAML
  end

  def queue
    return @queue if @queue

    case RUBY_PLATFORM
    when /linux/
      require 'localjob/linux_adapter'
      @queue = LinuxAdapter.new(@name)
    else
      require 'localjob/sysv_adapter'
      @queue = SysvAdapter.new(@name)
    end
  end

  def <<(object)
    queue.send serializer.dump(object)
  end

  def shift
    serializer.load queue.receive
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
localjob-0.1.0 lib/localjob.rb