Sha256: 2d446fe7162471a1506760ea56418742c534a1409aef69986163229f81d4028c

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 Bytes

Contents

# frozen_string_literal: true

module Del
  # Executes shell commands and pipes the
  # results back to the caller.
  class ShellCommand
    def initialize(command)
      @command = Array(command).flatten.join(' ')
    end

    def run
      Open3.popen3(@command) do |_stdin, stdout, stderr, wait_thr|
        stdout.each_line { |line| yield line }
        stderr.each_line { |line| yield line }
        wait_thr.value.success?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
del-0.1.19 lib/del/shell_command.rb
del-0.1.18 lib/del/shell_command.rb
del-0.1.17 lib/del/shell_command.rb