Class: SubshellCommand::StandardOutputStreamsExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/subshell_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_object, result) ⇒ StandardOutputStreamsExecutor

Returns a new instance of StandardOutputStreamsExecutor.



62
63
64
65
# File 'lib/subshell_command.rb', line 62

def initialize(command_object, result)
  @command_object = command_object
  @result = result
end

Instance Attribute Details

#command_objectObject (readonly)

Returns the value of attribute command_object.



60
61
62
# File 'lib/subshell_command.rb', line 60

def command_object
  @command_object
end

#resultObject (readonly)

Returns the value of attribute result.



60
61
62
# File 'lib/subshell_command.rb', line 60

def result
  @result
end

Instance Method Details

#executeObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/subshell_command.rb', line 67

def execute
  Open3.popen3(
    command_object.env_hash,
    command_object.command_string,
    chdir: command_object.current_directory,
  ) do |stdin, stdout, stderr, wait_thr|
    exit_status = wait_thr.value
    result.stdout_value = stdout.read
    result.stderr_value = stderr.read
    result.success = exit_status.success?
  end
end