Sha256: a7ca10bb946b74ef995261c36c41f6f3f266959e9e0c224e89ebde156d4c4740
Contents?: true
Size: 846 Bytes
Versions: 1
Compression:
Stored size: 846 Bytes
Contents
require_relative "../backsum" require "cocaine" require 'posix/spawn' module Backsum class Shell def initialize(command, params = "", options = {}) options[:runner] ||= LoggablePosixRunner.new @command_line = Cocaine::CommandLine.new(command, params, options) end def run(*args) @command_line.run(*args) end end class LoggablePosixRunner def call(command, env = {}) input, output = IO.pipe pid = spawn(env, command, :out => output) output.close result = "" while line = input.readline Backsum.logger.debug(line.chomp) result << line end rescue EOFError waitpid(pid) input.close result end def spawn(*args) ::POSIX::Spawn.spawn(*args) end def waitpid(pid) ::Process.waitpid(pid) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
backsum-0.0.1 | lib/backsum/shell.rb |