Class: Verto::SystemCommandExecutor
- Inherits:
-
Object
- Object
- Verto::SystemCommandExecutor
- Defined in:
- lib/verto/utils/system_command_executor.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Method Summary collapse
Instance Method Details
#run(command) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/verto/utils/system_command_executor.rb', line 20 def run(command) stderr&.puts running_log(command, path) Open3.popen3(command, chdir: path.to_s) do |_, stdout, stderr, wait_thread| @output = stdout.read @error = stderr.read @result = wait_thread.value end stdout << @output if stdout stderr << @error if stderr Result.new(@output, @error, @result) end |
#run!(command) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/verto/utils/system_command_executor.rb', line 35 def run!(command) result = run(command) raise Error, @error unless @error.empty? result end |