Class: Cuprum::Cli::Integrations::Thor::Task::Builder
- Inherits:
-
Object
- Object
- Cuprum::Cli::Integrations::Thor::Task::Builder
- Extended by:
- Forwardable
- Defined in:
- lib/cuprum/cli/integrations/thor/task.rb
Overview
Generates a Thor::Task wrapping a Cuprum::Cli command class.
Instance Attribute Summary collapse
-
#command_class ⇒ Class
readonly
The command to execute.
Instance Method Summary collapse
-
#build(full_name: nil) ⇒ Class
Generates a Thor::Task wrapping the command class.
-
#initialize(command_class) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(command_class) ⇒ Builder
Returns a new instance of Builder.
25 26 27 28 29 30 |
# File 'lib/cuprum/cli/integrations/thor/task.rb', line 25 def initialize(command_class) validate_command_class(command_class) @command_class = command_class @full_name = nil end |
Instance Attribute Details
#command_class ⇒ Class (readonly)
Returns the command to execute.
33 34 35 |
# File 'lib/cuprum/cli/integrations/thor/task.rb', line 33 def command_class @command_class end |
Instance Method Details
#build(full_name: nil) ⇒ Class
Generates a Thor::Task wrapping the command class.
The generated task will be assigned Thor metadata automatically, based on the configuration of the command class.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cuprum/cli/integrations/thor/task.rb', line 47 def build(full_name: nil) @full_name = full_name || command_class.full_name tools.assertions.validate_name(@full_name, as: 'full_name') Cuprum::Cli::Integrations::Thor::Task .subclass(command_class) .tap do |task| (task) task.alias_method short_name, :call_command end end |