Class: SSHKit::Custom::Runner::Abstract Abstract
- Inherits:
-
Object
- Object
- SSHKit::Custom::Runner::Abstract
- Defined in:
- lib/sshkit/custom/runner/abstract.rb
Overview
This class is abstract.
Subclass and override #apply_block_to_bcks to implement
Base class for all runners
Direct Known Subclasses
Instance Attribute Summary collapse
- #backends ⇒ Object
- #options ⇒ Object readonly
- #wait_interval ⇒ Object writeonly
Class Method Summary collapse
-
.create_runner(opts) ⇒ Object
Factory method to create a new runner.
Instance Method Summary collapse
- #apply_block_to_bcks(&_block) ⇒ Object abstract
-
#initialize(options = nil) ⇒ Abstract
constructor
A new instance of Abstract.
-
#send_cmd(cmd, *args, &block) ⇒ Object
Sends the given command to the backend.
Constructor Details
#initialize(options = nil) ⇒ Abstract
Returns a new instance of Abstract.
52 53 54 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 52 def initialize( = nil) = || {} end |
Instance Attribute Details
#backends ⇒ Object
12 13 14 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 12 def backends @backends end |
#options ⇒ Object (readonly)
13 14 15 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 13 def end |
#wait_interval=(value) ⇒ Object
14 15 16 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 14 def wait_interval=(value) @wait_interval = value end |
Class Method Details
.create_runner(opts) ⇒ Object
Factory method to create a new runner.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 17 def self.create_runner(opts) opts_with_defaults = { in: :parallel }.merge(opts) case opts_with_defaults[:in] when :parallel Parallel when :sequence Sequential when :groups Group else fail "Don't know how to handle run style #{opts_with_defaults[:in].inspect}" end.new(opts_with_defaults) end |
Instance Method Details
#apply_block_to_bcks(&_block) ⇒ Object
This method is abstract.
79 80 81 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 79 def apply_block_to_bcks(&_block) fail SSHKit::Backend::MethodUnavailableError end |
#send_cmd(cmd, *args, &block) ⇒ Object
Sends the given command to the backend.
70 71 72 73 74 75 76 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 70 def send_cmd(cmd, *args, &block) args = Array(block.call(active_backend.host)) if block active_backend.send(cmd, *args) rescue => e e2 = ExecuteError.new e raise e2, "Exception while executing on host #{active_backend.host}: #{e.message}" end |