class SSHake::ExecutionOptions

Attributes

default_timeout[W]
file_to_stream[RW]

A file that you wish to stream to the remote channel with the current commend

@return [File]

raise_on_error[RW]

Should errors be raised?

@return [Boolean]

stderr[RW]

A proc to call whenever data is received on stderr

@return [Proc]

stdin[RW]

The data to pass to stdin when executing this command

@return [String]

stdout[RW]

A proc to call whenever data is received on stdout

@return [Proc]

sudo_password[RW]

The password to be provided to the interactive sudo prompt

@return [String]

sudo_user[RW]

The user to execute sudo commands as. If nil, commands will not be executed with sudo.

@return [String]

timeout[W]

Public Class Methods

default_timeout() click to toggle source

Return the default timeout

@return [Integer]

# File lib/sshake/execution_options.rb, line 65
def default_timeout
  @default_timeout || 60
end
from_block() { |dsl| ... } click to toggle source

Create a new set of options from a block

@return [SSHake::ExecutionOptions]

# File lib/sshake/execution_options.rb, line 99
def from_block
  options = new
  dsl = ExecutionOptionsDSL.new(options)
  yield dsl
  options
end
from_hash(hash) click to toggle source

Create a new set of options from a given hash

@param [Hash] hash @return [SSHake::ExecutionOptions]

# File lib/sshake/execution_options.rb, line 74
def from_hash(hash)
  options = new
  options.timeout = hash[:timeout]
  case hash[:sudo]
  when String
    options.sudo_user = hash[:sudo]
  when Hash
    options.sudo_user = hash[:sudo][:user] || 'root'
    options.sudo_password = hash[:sudo][:password]
  when true
    options.sudo_user = 'root'
  end
  # rubocop:disable Style/DoubleNegation
  options.raise_on_error = !!hash[:raise_on_error]
  # rubocop:enable Style/DoubleNegation
  options.stdin = hash[:stdin]
  options.stdout = hash[:stdout]
  options.stderr = hash[:stderr]
  options.file_to_stream = hash[:file_to_stream]
  options
end

Public Instance Methods

raise_on_error?() click to toggle source

Should errors be raised

@return [Boolean]

# File lib/sshake/execution_options.rb, line 56
def raise_on_error?
  !!@raise_on_error
end
timeout() click to toggle source

The timeout

@return [Integer]

# File lib/sshake/execution_options.rb, line 11
def timeout
  @timeout || self.class.default_timeout
end