Sha256: fab710cc02f745f2e65f66da2340b52264bb9ae565884a8a8a7be60438559b2a

Contents?: true

Size: 654 Bytes

Versions: 2

Compression:

Stored size: 654 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
      # $stdout.print(".")
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
invoker-0.0.3 lib/invoker/command_worker.rb
invoker-0.0.2 lib/invoker/command_worker.rb