Class: RVGP::Base::Command::ReconcilerTarget
- Defined in:
- lib/rvgp/base/command.rb
Overview
This is an implementation of Target, that matches Reconcilers.
This class allows any of the current project’s reconcilers to match a target. And, such targets can be selected by way of a:
-
full reconciler path
-
reconciler file basename (without the full path)
-
the reconciler’s from field
-
the reconciler’s label field
-
the reconciler’s input file
-
the reconciler’s output file
Any class that operates by way of a reconciler-defined target, can use this implementation, in lieu of re-implementing the wheel.
Instance Attribute Summary
Attributes inherited from Target
Class Method Summary collapse
-
.all ⇒ Array<RVGP::Base::Command::ReconcilerTarget>
All possible Reconciler Targets that the project has defined.
-
.command ⇒ Symbol
Returns which command this class is defined for.
-
.for_command(underscorized_command_name) ⇒ Object
This is a little goofy.
Instance Method Summary collapse
-
#description ⇒ Object
A description of this target.
-
#initialize(reconciler) ⇒ ReconcilerTarget
constructor
Create a new ReconcilerTarget.
-
#matches?(identifier) ⇒ TrueClass, FalseClass
Returns true, if the provided identifier matches this target.
Methods inherited from Target
Constructor Details
#initialize(reconciler) ⇒ ReconcilerTarget
Create a new ReconcilerTarget
89 90 91 92 |
# File 'lib/rvgp/base/command.rb', line 89 def initialize(reconciler) super reconciler.as_taskname, reconciler.label @reconciler = reconciler end |
Class Method Details
.all ⇒ Array<RVGP::Base::Command::ReconcilerTarget>
All possible Reconciler Targets that the project has defined.
106 107 108 |
# File 'lib/rvgp/base/command.rb', line 106 def self.all RVGP.app.reconcilers.map { |reconciler| new reconciler } end |
.command ⇒ Symbol
Returns which command this class is defined for. See the note in #for_command.
122 123 124 |
# File 'lib/rvgp/base/command.rb', line 122 def self.command @for_command end |
.for_command(underscorized_command_name) ⇒ Object
This is a little goofy. But, it exists as a hack to support dispatching this target via the command method. You can see an example of this at work in the reconcile.rb file.
115 116 117 |
# File 'lib/rvgp/base/command.rb', line 115 def self.for_command(underscorized_command_name) @for_command = underscorized_command_name end |
Instance Method Details
#description ⇒ Object
A description of this target. Mostly this is used by rake, to describe this target in the ‘rake -T’ output.
100 101 102 |
# File 'lib/rvgp/base/command.rb', line 100 def description I18n.t format('commands.%s.target_description', self.class.command), input_file: @reconciler.input_file end |
#matches?(identifier) ⇒ TrueClass, FalseClass
Returns true, if the provided identifier matches this target
95 96 97 |
# File 'lib/rvgp/base/command.rb', line 95 def matches?(identifier) @reconciler.matches_argument? identifier end |