Sha256: ce7b882657cec15288fcf8afd3f8fec700662c803e46b97132e88a6218113315

Contents?: true

Size: 748 Bytes

Versions: 3

Compression:

Stored size: 748 Bytes

Contents

module Invoker
  class CommandWorker
    attr_accessor :command_label, :pipe_end, :pid, :color
    
    def initialize(command_label, pipe_end, pid, color)
      @command_label = command_label
      @pipe_end = pipe_end
      @pid = pid
      @color = color
    end

    # Copied verbatim from Eventmachine code
    def receive_data data
      (@buf ||= '') << data

      while @buf.slice!(/(.*?)\r?\n/)
        receive_line($1)
      end
    end

    def unbind
      Invoker::Logger.print(".")
    end

    # Print the lines received over the network
    def receive_line(line)
      Invoker::Logger.puts "#{@command_label.send(color)} : #{line}"
    end

    def to_h
      {:command_label => command_label, :pid => pid.to_s}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
invoker-0.1.2 lib/invoker/command_worker.rb
invoker-0.1.1 lib/invoker/command_worker.rb
invoker-0.1.1.pre lib/invoker/command_worker.rb