class Aruba::Platforms::WindowsCommandString

This is a command which should be run

This adds `cmd.exec` in front of commmand

@private

Public Class Methods

new(command, *arguments) click to toggle source
# File lib/aruba/platforms/windows_command_string.rb, line 11
def initialize(command, *arguments)
  @command = command
  @arguments = arguments
end

Public Instance Methods

to_a() click to toggle source

Convert to array

# File lib/aruba/platforms/windows_command_string.rb, line 17
def to_a
  [cmd_path, "/c", [escaped_command, *escaped_arguments].join(" ")]
end

Private Instance Methods

cmd_path() click to toggle source
# File lib/aruba/platforms/windows_command_string.rb, line 32
def cmd_path
  Aruba.platform.which("cmd.exe")
end
escaped_arguments() click to toggle source
# File lib/aruba/platforms/windows_command_string.rb, line 23
def escaped_arguments
  @arguments.map { |arg| arg.gsub(/"/, '"""') }
            .map { |arg| / /.match?(arg) ? "\"#{arg}\"" : arg }
end
escaped_command() click to toggle source
# File lib/aruba/platforms/windows_command_string.rb, line 28
def escaped_command
  @command.gsub(/ /, '""" """')
end