Sha256: f512a808b77c8c68fd93218a69cfbd1ad0b4383689758779fe2f65a28e952364

Contents?: true

Size: 608 Bytes

Versions: 3

Compression:

Stored size: 608 Bytes

Contents

require 'open3'
require 'colorize'

module Execution

  Thread.abort_on_exception = true

  def threadexec(command, prefix = nil, color = nil)

    unless prefix.nil?
      prefix = "#{prefix}    | "
    end

    if color.nil?
      color = :cyan
    end

    Thread.new {
      Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|

        while lineOut = stdout.gets
          puts prefix.nil? ? lineOut : prefix.colorize(color) + lineOut
        end

        while lineErr = stderr.gets
          puts prefix.nil? ? lineErr : prefix.colorize(color) + lineErr
        end

      end
    }

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docker-sync-0.0.6 lib/execution.rb
docker-sync-0.0.5 lib/execution.rb
docker-sync-0.0.4 lib/execution.rb