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
-
#initialize {|dsl| ... } ⇒ ExecutionOptions
constructor
A new instance of ExecutionOptions.
-
#raise_on_error? ⇒ Boolean
Should errors be raised.
Constructor Details
#initialize {|dsl| ... } ⇒ ExecutionOptions
Returns a new instance of ExecutionOptions.
8 9 10 11 |
# File 'lib/sshake/execution_options.rb', line 8 def initialize dsl = ExecutionOptionsDSL.new(self) yield dsl if block_given? end |
Class Attribute Details
.default_timeout ⇒ Integer
Return the default timeout
70 71 72 |
# File 'lib/sshake/execution_options.rb', line 70 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
56 57 58 |
# File 'lib/sshake/execution_options.rb', line 56 def file_to_stream @file_to_stream end |
#raise_on_error ⇒ Boolean
Should errors be raised?
35 36 37 |
# File 'lib/sshake/execution_options.rb', line 35 def raise_on_error @raise_on_error end |
#stderr ⇒ Proc
A proc to call whenever data is received on stderr
50 51 52 |
# File 'lib/sshake/execution_options.rb', line 50 def stderr @stderr end |
#stdin ⇒ String
The data to pass to stdin when executing this command
40 41 42 |
# File 'lib/sshake/execution_options.rb', line 40 def stdin @stdin end |
#stdout ⇒ Proc
A proc to call whenever data is received on stdout
45 46 47 |
# File 'lib/sshake/execution_options.rb', line 45 def stdout @stdout end |
#sudo_password ⇒ String
The password to be provided to the interactive sudo prompt
30 31 32 |
# File 'lib/sshake/execution_options.rb', line 30 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.
25 26 27 |
# File 'lib/sshake/execution_options.rb', line 25 def sudo_user @sudo_user end |
#timeout ⇒ Integer
The timeout
16 17 18 |
# File 'lib/sshake/execution_options.rb', line 16 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
104 105 106 107 108 109 |
# File 'lib/sshake/execution_options.rb', line 104 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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/sshake/execution_options.rb', line 79 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
61 62 63 |
# File 'lib/sshake/execution_options.rb', line 61 def raise_on_error? !!@raise_on_error end |