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 rubocop:disable Performance/RedundantBlockCall
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.
53 54 55 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 53 def initialize( = nil) @options = || {} end |
Instance Attribute Details
#backends ⇒ Object
13 14 15 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 13 def backends @backends end |
#options ⇒ Object (readonly)
14 15 16 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 14 def @options end |
#wait_interval=(value) ⇒ Object
15 16 17 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 15 def wait_interval=(value) @wait_interval = value end |
Class Method Details
.create_runner(opts) ⇒ Object
Factory method to create a new runner.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 18 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 raise "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.
80 81 82 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 80 def apply_block_to_bcks(&_block) raise SSHKit::Backend::MethodUnavailableError end |
#send_cmd(cmd, *args, &block) ⇒ Object
Sends the given command to the backend.
71 72 73 74 75 76 77 |
# File 'lib/sshkit/custom/runner/abstract.rb', line 71 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.}" end |