Class: Sevgi::Function::Shell::Runner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sevgi/function/shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Runs shell commands and captures stdout, stderr, and exit status.

Instance Method Summary collapse

Constructor Details

#initializevoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a shell runner.



177
178
179
# File 'lib/sevgi/function/shell.rb', line 177

def initialize
  @coathooks = 0
end

Instance Method Details

#call(*args) { ... } ⇒ Sevgi::Function::Shell::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs a command and captures its output.

Parameters:

  • args (Array<String>)

    command and arguments

Yields:

  • optional content writer for stdin

Yield Returns:

Returns:

Raises:

  • (Errno::ENOENT)

    when the executable cannot be spawned



187
188
189
190
191
192
193
194
195
196
# File 'lib/sevgi/function/shell.rb', line 187

def call(*args, &input)
  return Result.dummy if args.empty?

  @coathooks = 0
  outs, errs, status = Open3.popen3(*args) do |stdin, stdout, stderr, wait_thread|
    capture(stdin, stdout, stderr, wait_thread, &input)
  end

  Result.new(args, outs, errs, status.exitstatus)
end