Class: RVM::Shell::SingleShotWrapper

Inherits:
AbstractWrapper show all
Defined in:
lib/rvm/shell/single_shot_wrapper.rb

Overview

Implementation of the abstract wrapper class that opens a new instance of bash when a command is run, only keeping it around for the lifetime of the command. Possibly inefficient but for the moment simplest and hence default implementation.

Constant Summary

Constants inherited from AbstractWrapper

AbstractWrapper::COMMAND_EPILOG_END, AbstractWrapper::COMMAND_EPILOG_START, AbstractWrapper::WRAPPER_LOCATION

Instance Attribute Summary collapse

Attributes inherited from AbstractWrapper

#shell_executable

Instance Method Summary collapse

Methods inherited from AbstractWrapper

#[], #initialize, #run, #run_silently, #setup

Methods included from Utility

#build_cli_call, #escape_argument, #escape_arguments

Constructor Details

This class inherits a constructor from RVM::Shell::AbstractWrapper

Instance Attribute Details

#currentObject

Returns the value of attribute current.



11
12
13
# File 'lib/rvm/shell/single_shot_wrapper.rb', line 11

def current
  @current
end

Instance Method Details

#run_command(command) ⇒ Object

Runs a given command in the current shell. Defaults the command to true if empty.



15
16
17
18
19
20
21
22
23
24
# File 'lib/rvm/shell/single_shot_wrapper.rb', line 15

def run_command(command)
  command = "true" if command.to_s.strip.empty?
  with_shell_instance do
    stdin.puts wrapped_command(command)
    stdin.close
    out, err = stdout.read, stderr.read
    out, status, _ = raw_stdout_to_parts(out)
    return status, out, err
  end
end

#run_command_silently(command) ⇒ Object

Runs a command, ensuring no output is collected.



27
28
29
30
31
# File 'lib/rvm/shell/single_shot_wrapper.rb', line 27

def run_command_silently(command)
  with_shell_instance do
    stdin.puts silent_command(command)
  end
end