Class: CemAcpt::Bolt::TaskWrapper
- Inherits:
-
Object
- Object
- CemAcpt::Bolt::TaskWrapper
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/bolt/tasks.rb
Overview
Provides a wrapper for Bolt tasks that holds data and provides methods for interacting with them This should probably be genericized as ObjectWrapper to account for Bolt plans, as well
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#last_cmd_executed ⇒ Object
readonly
Returns the value of attribute last_cmd_executed.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(config, task_array, project: nil, inventory: nil) ⇒ TaskWrapper
constructor
A new instance of TaskWrapper.
- #inspect ⇒ Object
- #run(**params) ⇒ Object
- #show(**params) ⇒ Object
Methods included from Logging
current_log_config, #current_log_config, current_log_format, #current_log_format, #current_log_level, current_log_level, included, #logger, logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, #new_log_level, new_log_level, #new_logger, new_logger, verbose?, #verbose?
Constructor Details
#initialize(config, task_array, project: nil, inventory: nil) ⇒ TaskWrapper
Returns a new instance of TaskWrapper.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 20 def initialize(config, task_array, project: nil, inventory: nil) @config = config @full_name = task_array[0] @description = task_array[1] @module_name = @full_name.split('::').first @name = @full_name.split('::').last @show_cmd = CemAcpt::Bolt::Cmd::TaskShow.new(@config, full_name, project: project) @run_cmd = CemAcpt::Bolt::Cmd::TaskRun.new(@config, full_name, project: project, inventory: inventory) @last_cmd_executed = nil end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
18 19 20 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 18 def description @description end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
18 19 20 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 18 def full_name @full_name end |
#last_cmd_executed ⇒ Object (readonly)
Returns the value of attribute last_cmd_executed.
18 19 20 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 18 def last_cmd_executed @last_cmd_executed end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
18 19 20 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 18 def module_name @module_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 18 def name @name end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 31 def inspect "#<#{self.class}:\"#{full_name}\">" end |
#run(**params) ⇒ Object
41 42 43 44 45 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 41 def run(**params) logger.verbose('CemAcpt::Bolt::TaskWrapper') { "Executing task run with params: #{params}" } @last_cmd_executed = @run_cmd run_cmd.run(**params) end |
#show(**params) ⇒ Object
35 36 37 38 39 |
# File 'lib/cem_acpt/bolt/tasks.rb', line 35 def show(**params) logger.verbose('CemAcpt::Bolt::TaskWrapper') { "Executing task show with params: #{params}" } @last_cmd_executed = @show_cmd show_cmd.run(**params) end |