Class: SSHake::ExecutionOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/sshake/execution_options.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.default_timeoutInteger

Return the default timeout

Returns:

  • (Integer)


61
62
63
# File 'lib/sshake/execution_options.rb', line 61

def default_timeout
  @default_timeout || 60
end

Instance Attribute Details

#file_to_streamObject

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

 @return [File]



48
49
50
# File 'lib/sshake/execution_options.rb', line 48

def file_to_stream
  @file_to_stream
end

#raise_on_errorBoolean

Should errors be raised?

Returns:

  • (Boolean)


27
28
29
# File 'lib/sshake/execution_options.rb', line 27

def raise_on_error
  @raise_on_error
end

#stderrProc

A proc to call whenever data is received on stderr

Returns:

  • (Proc)


42
43
44
# File 'lib/sshake/execution_options.rb', line 42

def stderr
  @stderr
end

#stdinString

The data to pass to stdin when executing this command

Returns:

  • (String)


32
33
34
# File 'lib/sshake/execution_options.rb', line 32

def stdin
  @stdin
end

#stdoutProc

A proc to call whenever data is received on stdout

Returns:

  • (Proc)


37
38
39
# File 'lib/sshake/execution_options.rb', line 37

def stdout
  @stdout
end

#sudo_passwordString

The password to be provided to the interactive sudo prompt

Returns:

  • (String)


22
23
24
# File 'lib/sshake/execution_options.rb', line 22

def sudo_password
  @sudo_password
end

#sudo_userString

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

Returns:

  • (String)


17
18
19
# File 'lib/sshake/execution_options.rb', line 17

def sudo_user
  @sudo_user
end

#timeoutInteger

The timeout

Returns:

  • (Integer)


8
9
10
# File 'lib/sshake/execution_options.rb', line 8

def timeout
  @timeout || self.class.default_timeout
end

Class Method Details

.from_block {|dsl| ... } ⇒ SSHake::ExecutionOptions

Create a new set of options from a block

Yields:

  • (dsl)

Returns:



92
93
94
95
96
97
# File 'lib/sshake/execution_options.rb', line 92

def from_block
  options = new
  dsl = ExecutionOptionsDSL.new(options)
  yield dsl
  options
end

.from_hash(hash) ⇒ SSHake::ExecutionOptions

Create a new set of options from a given hash

Parameters:

  • hash (Hash)

Returns:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/sshake/execution_options.rb', line 70

def from_hash(hash)
  options = new
  options.timeout = hash[:timeout]
  if hash[:sudo].is_a?(String)
    options.sudo_user = hash[:sudo]
  elsif hash[:sudo].is_a?(Hash)
    options.sudo_user = hash[:sudo][:user]
    options.sudo_password = hash[:sudo][:password]
  elsif hash[:sudo] == true
    options.sudo_user = 'root'
  end
  options.raise_on_error = !!hash[:raise_on_error]
  options.stdin = hash[:stdin]
  options.stdout = hash[:stdout]
  options.stderr = hash[:stderr]
  options.file_to_stream = hash[:file_to_stream]
  options
end

Instance Method Details

#raise_on_error?Boolean

Should errors be raised

Returns:

  • (Boolean)


53
54
55
# File 'lib/sshake/execution_options.rb', line 53

def raise_on_error?
  !!@raise_on_error
end