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 ⇒ Object
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
61 62 63 |
# File 'lib/sshake/execution_options.rb', line 61 def default_timeout @default_timeout || 60 end |
Instance Attribute Details
#file_to_stream ⇒ Object
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_error ⇒ Boolean
Should errors be raised?
27 28 29 |
# File 'lib/sshake/execution_options.rb', line 27 def raise_on_error @raise_on_error end |
#stderr ⇒ Proc
A proc to call whenever data is received on stderr
42 43 44 |
# File 'lib/sshake/execution_options.rb', line 42 def stderr @stderr end |
#stdin ⇒ String
The data to pass to stdin when executing this command
32 33 34 |
# File 'lib/sshake/execution_options.rb', line 32 def stdin @stdin end |
#stdout ⇒ Proc
A proc to call whenever data is received on stdout
37 38 39 |
# File 'lib/sshake/execution_options.rb', line 37 def stdout @stdout end |
#sudo_password ⇒ String
The password to be provided to the interactive sudo prompt
22 23 24 |
# File 'lib/sshake/execution_options.rb', line 22 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.
17 18 19 |
# File 'lib/sshake/execution_options.rb', line 17 def sudo_user @sudo_user end |
#timeout ⇒ Integer
The timeout
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
92 93 94 95 96 97 |
# File 'lib/sshake/execution_options.rb', line 92 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
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) = new .timeout = hash[:timeout] if hash[:sudo].is_a?(String) .sudo_user = hash[:sudo] elsif hash[:sudo].is_a?(Hash) .sudo_user = hash[:sudo][:user] .sudo_password = hash[:sudo][:password] elsif hash[:sudo] == true .sudo_user = 'root' end .raise_on_error = !!hash[:raise_on_error] .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
53 54 55 |
# File 'lib/sshake/execution_options.rb', line 53 def raise_on_error? !!@raise_on_error end |