Class: SSHake::ExecutionOptions
- Inherits:
-
Object
- Object
- SSHake::ExecutionOptions
- Defined in:
- lib/sshake/execution_options.rb
Class Attribute Summary collapse
-
.default_timeout ⇒ Integer
Return the default timeout.
Instance Attribute Summary collapse
-
#file_to_stream ⇒ File
A file that you wish to stream to the remote channel with the current commend.
-
#raise_on_error ⇒ Boolean
Should errors be raised?.
-
#stderr ⇒ Proc
A proc to call whenever data is received on stderr.
-
#stdin ⇒ String
The data to pass to stdin when executing this command.
-
#stdout ⇒ Proc
A proc to call whenever data is received on stdout.
-
#sudo_password ⇒ String
The password to be provided to the interactive sudo prompt.
-
#sudo_user ⇒ String
The user to execute sudo commands as.
-
#timeout ⇒ Integer
The timeout.
Class Method Summary collapse
-
.from_block {|dsl| ... } ⇒ SSHake::ExecutionOptions
Create a new set of options from a block.
-
.from_hash(hash) ⇒ SSHake::ExecutionOptions
Create a new set of options from a given hash.
Instance Method Summary collapse
-
#raise_on_error? ⇒ Boolean
Should errors be raised.
Class Attribute Details
.default_timeout ⇒ Integer
Return the default timeout
65 66 67 |
# File 'lib/sshake/execution_options.rb', line 65 def default_timeout @default_timeout || 60 end |
Instance Attribute Details
#file_to_stream ⇒ File
A file that you wish to stream to the remote channel with the current commend
51 52 53 |
# File 'lib/sshake/execution_options.rb', line 51 def file_to_stream @file_to_stream end |
#raise_on_error ⇒ Boolean
Should errors be raised?
30 31 32 |
# File 'lib/sshake/execution_options.rb', line 30 def raise_on_error @raise_on_error end |
#stderr ⇒ Proc
A proc to call whenever data is received on stderr
45 46 47 |
# File 'lib/sshake/execution_options.rb', line 45 def stderr @stderr end |
#stdin ⇒ String
The data to pass to stdin when executing this command
35 36 37 |
# File 'lib/sshake/execution_options.rb', line 35 def stdin @stdin end |
#stdout ⇒ Proc
A proc to call whenever data is received on stdout
40 41 42 |
# File 'lib/sshake/execution_options.rb', line 40 def stdout @stdout end |
#sudo_password ⇒ String
The password to be provided to the interactive sudo prompt
25 26 27 |
# File 'lib/sshake/execution_options.rb', line 25 def sudo_password @sudo_password end |
#sudo_user ⇒ String
The user to execute sudo commands as. If nil, commands will not be executed with sudo.
20 21 22 |
# File 'lib/sshake/execution_options.rb', line 20 def sudo_user @sudo_user end |
#timeout ⇒ Integer
The timeout
11 12 13 |
# File 'lib/sshake/execution_options.rb', line 11 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
99 100 101 102 103 104 |
# File 'lib/sshake/execution_options.rb', line 99 def from_block = new dsl = ExecutionOptionsDSL.new() yield dsl end |
.from_hash(hash) ⇒ SSHake::ExecutionOptions
Create a new set of options from a given hash
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sshake/execution_options.rb', line 74 def from_hash(hash) = new .timeout = hash[:timeout] case hash[:sudo] when String .sudo_user = hash[:sudo] when Hash .sudo_user = hash[:sudo][:user] || 'root' .sudo_password = hash[:sudo][:password] when true .sudo_user = 'root' end # rubocop:disable Style/DoubleNegation .raise_on_error = !!hash[:raise_on_error] # rubocop:enable Style/DoubleNegation .stdin = hash[:stdin] .stdout = hash[:stdout] .stderr = hash[:stderr] .file_to_stream = hash[:file_to_stream] end |
Instance Method Details
#raise_on_error? ⇒ Boolean
Should errors be raised
56 57 58 |
# File 'lib/sshake/execution_options.rb', line 56 def raise_on_error? !!@raise_on_error end |