Class: RVGP::Base::Command::Target
- Inherits:
-
Object
- Object
- RVGP::Base::Command::Target
- Defined in:
- lib/rvgp/base/command.rb
Overview
Targets are, as the name would imply, a command line argument, that isn’t prefixed with one or more dashes. Whereas some arguments are program options, targets are typically a specific subject or destination, which the command is applied to.
This base class offers common functions for navigating targets, and identifying targets on the command line. This is a base class, which would generally find an inheritor inside a specific command’s implementation.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
A description of this target.
-
#name ⇒ String
readonly
The target name, as it would be expected to be found on the CLI.
-
#status_name ⇒ String
readonly
The target name, as it would be expected to appear in the status output, which is generally displayed during the processing of this target during the rake process and/or during an rvgp-triggered process.
Class Method Summary collapse
-
.from_s(str) ⇒ Target
Find the target that matches the provided string.
Instance Method Summary collapse
-
#initialize(name, status_name = nil) ⇒ Target
constructor
Create a new Target.
-
#matches?(identifier) ⇒ TrueClass, FalseClass
Returns true, if the provided identifier matches this target.
Constructor Details
#initialize(name, status_name = nil) ⇒ Target
Create a new Target
51 52 53 54 |
# File 'lib/rvgp/base/command.rb', line 51 def initialize(name, status_name = nil) @name = name @status_name = status_name end |
Instance Attribute Details
#description ⇒ String (readonly)
A description of this target. Mostly this is used by rake, to describe this target in the ‘rake -T’ output.
45 46 47 |
# File 'lib/rvgp/base/command.rb', line 45 def description @description end |
#name ⇒ String (readonly)
The target name, as it would be expected to be found on the CLI
45 46 47 |
# File 'lib/rvgp/base/command.rb', line 45 def name @name end |
#status_name ⇒ String (readonly)
The target name, as it would be expected to appear in the status output, which is generally displayed during the processing of this target during the rake process and/or during an rvgp-triggered process.
45 46 47 |
# File 'lib/rvgp/base/command.rb', line 45 def status_name @status_name end |
Class Method Details
.from_s(str) ⇒ Target
Find the target that matches the provided string
66 67 68 |
# File 'lib/rvgp/base/command.rb', line 66 def self.from_s(str) all.find_all { |target| target.matches? str } end |
Instance Method Details
#matches?(identifier) ⇒ TrueClass, FalseClass
Returns true, if the provided identifier matches this target
59 60 61 |
# File 'lib/rvgp/base/command.rb', line 59 def matches?(identifier) File.fnmatch? identifier, name end |