Sha256: 7cede8f9740164c2ae8be1fb71a8a361b74bb90ea13f050002833a087a8b9614

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# Implementation of sh from github-gem
# https://github.com/defunkt/github-gem

module Tonic
  class Shell < String

    attr_reader :error
    attr_reader :out

    def self.run(*command)
      self.new(*command).run
    end

    def initialize(*command)
      @command = command
    end

    def run
      out = err = nil
      Open3.popen3(*@command) do |_, pout, perr|
        out = pout.read.strip
        err = perr.read.strip
      end

      replace @error = err unless err.empty?
      replace @out = out unless out.empty?

      self
    end

    def command
      @command.join(' ')
    end

    def error?
      !!@error
    end

    def out?
      !!@out
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tonic-0.0.1 lib/tonic/shell.rb