Class: Kitchen::Transport::Localhost::Connection

Inherits:
Base::Connection
  • Object
show all
Includes:
Localhost::ShellOut
Defined in:
lib/kitchen/transport/localhost/connection.rb

Overview

Connection class for the Localhost transport.

Author:

Instance Method Summary collapse

Methods included from Localhost::ShellOut

#cp_r, #mkdir_p, #rm_rf, #run_command, #run_command_psh, #run_command_sh, #windows_os?

Instance Method Details

#execute(command) ⇒ Object

Execute a given command. Use the ShellOut helpers so the command is run through PowerShell on Windows systems and the regular command line everywhere else.

(see Base::Connection#execute)

Raises:



44
45
46
47
48
49
50
51
52
# File 'lib/kitchen/transport/localhost/connection.rb', line 44

def execute(command)
  return if command.nil?
  logger.debug("[Localhost] Executing command '#{command}'")
  begin
    Bundler.with_clean_env { run_command(command) }
  rescue StandardError => err
    raise(Kitchen::Transport::LocalhostFailed, err.message)
  end
end

#upload(locals, remote) ⇒ Object

Upload a set of local files to a ‘remote’ (aka Kitchen temp dir). Use the ShellOut helpers to run the paths through PowerShell and resolve any input PSH variables.

(see Base::Connection#upload)



61
62
63
64
65
66
67
68
# File 'lib/kitchen/transport/localhost/connection.rb', line 61

def upload(locals, remote)
  mkdir_p(remote)
  Array(locals).each do |local|
    cp_r(local, remote)
    logger.debug("[Localhost] Copied '#{local}' to '#{remote}'")
  end
  logger.debug("[Localhost] File copying to '#{remote}' complete")
end