Class: R10K::Action::CriRunner Private
- Inherits:
-
Object
- Object
- R10K::Action::CriRunner
- Defined in:
- lib/r10k/action/cri_runner.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Adapt the Cri runner interface to the R10K::Action::Runner interface
This class provides the necessary glue to translate behavior specific to Cri and the CLI component in general to the interface agnostic runner class.
Direct Known Subclasses
Class Method Summary collapse
- .wrap(klass) ⇒ Object private
Instance Method Summary collapse
-
#call ⇒ Object
private
Invoke the wrapped behavior, determine if it succeeded, and exit with the resulting exit code.
-
#handle_argv(argv) ⇒ Array
private
The adapted arguments for the runner.
-
#handle_opts(opts) ⇒ Hash
private
The adapted options for the runner.
-
#initialize(klass) ⇒ CriRunner
constructor
private
A new instance of CriRunner.
-
#new(opts, argv, _cmd = nil) ⇒ self
private
Intercept any instatiations of klass.
Constructor Details
#initialize(klass) ⇒ CriRunner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CriRunner.
19 20 21 |
# File 'lib/r10k/action/cri_runner.rb', line 19 def initialize(klass) @klass = klass end |
Class Method Details
.wrap(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/r10k/action/cri_runner.rb', line 15 def self.wrap(klass) new(klass) end |
Instance Method Details
#call ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Invoke the wrapped behavior, determine if it succeeded, and exit with the resulting exit code.
69 70 71 72 |
# File 'lib/r10k/action/cri_runner.rb', line 69 def call rv = @runner.call exit(rv ? 0 : 1) end |
#handle_argv(argv) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The adapted arguments for the runner.
63 64 65 |
# File 'lib/r10k/action/cri_runner.rb', line 63 def handle_argv(argv) @argv = argv end |
#handle_opts(opts) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The adapted options for the runner.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/r10k/action/cri_runner.rb', line 43 def handle_opts(opts) # Translate from the Cri verbose logging option to the internal logging setting. loglevel = opts.delete(:verbose) case loglevel when String, Numeric opts[:loglevel] = loglevel when TrueClass opts[:loglevel] = 'INFO' when NilClass # pass else # When the type is unsure just pass it in as-is and let the internals # raise the appropriate errors. opts[:loglevel] = loglevel end @opts = opts end |
#new(opts, argv, _cmd = nil) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Intercept any instatiations of klass
Defining #new allows this object to proxy method calls on the wrapped runner and decorate various methods. Doing so allows this class to manage CLI specific behaviors and isolate the underlying code from having to deal with those particularities
35 36 37 38 39 40 |
# File 'lib/r10k/action/cri_runner.rb', line 35 def new(opts, argv, _cmd = nil) handle_opts(opts) handle_argv(argv) @runner = R10K::Action::Runner.new(@opts, @argv, @klass) self end |