class Reviewer::Arguments::Keywords
Handles interpreting all 'leftover' arguments and translating them to file-related, tag-related, or tool-related arguments
Constants
- RESERVED
Attributes
Public Class Methods
Generates an instace of parsed keywords from the provided arguments @param *provided [Array<String>] the leftover (non-flag) arguments from the command line
@return [Arguments::Keywords]
# File lib/reviewer/arguments/keywords.rb, line 18 def initialize(*provided) @provided = Array(provided.flatten) end
Public Instance Methods
Provides the complete list of all configured tool names for enabled tools
@return [Array<String>] all unique configured tools
# File lib/reviewer/arguments/keywords.rb, line 105 def configured_tool_names # We explicitly don't sort the tool names list because Reviewer uses the configuration order # to determine the execution order. So not sorting maintains the predicted order it will run # in and leaves the option to sort to the consuming code if needed tools.all.map { |tool| tool.key.to_s } end
Extracts keywords that match configured tool keys
@return [Array<String>] intersection of provided arguments and configured tool names
# File lib/reviewer/arguments/keywords.rb, line 70 def for_tool_names intersection_with configured_tool_names end
Provides the complete list of all recognized keywords based on configuration
@return [Array<String>] all keywords that Reviewer
can recognized
# File lib/reviewer/arguments/keywords.rb, line 91 def possible (RESERVED + configured_tags + configured_tool_names).uniq.sort end
Extracts keywords that match any possible recognized keyword values
@return [Array<String>] intersection of provided arguments and recognizable keywords
# File lib/reviewer/arguments/keywords.rb, line 77 def recognized intersection_with possible end
Extracts reserved keywords from the provided arguments
@return [Array<String>] intersection of provided arguments and reserved keywords
# File lib/reviewer/arguments/keywords.rb, line 56 def reserved intersection_with RESERVED end
Proves the full list of raw keyword arguments explicitly passed via command-line as an array
@return [Array] full collection of the provided keyword arguments as a string
# File lib/reviewer/arguments/keywords.rb, line 25 def to_a provided end
Summary of the state of keyword arguments based on how Reviewer
parsed them
@return [Hash] represents the summary of the keyword values parsed from the command-line and
grouped based on how they were parsed
# File lib/reviewer/arguments/keywords.rb, line 41 def to_h { provided: provided, recognized: recognized, unrecognized: unrecognized, reserved: reserved, for_tags: for_tags, for_tool_names: for_tool_names } end
Provides the full list of raw keyword arguments explicitly passed via command-line as a
comma-separated string
@return [String] comma-separated list of the file arguments as a string
# File lib/reviewer/arguments/keywords.rb, line 33 def to_s to_a.join(',') end
Extracts keywords that don't match any possible recognized keyword values
@return [Array<String>] leftover keywords that weren't recognized
# File lib/reviewer/arguments/keywords.rb, line 84 def unrecognized (provided - recognized).uniq.sort end
Private Instance Methods
Syntactic sugar for finding intersections with valid keywords @param values [Array<String>] the collection to use for finding intersecting values
@return [Array<String>] the list of intersecting values
# File lib/reviewer/arguments/keywords.rb, line 125 def intersection_with(values) (values & provided).uniq.sort end
Provides a collection of enabled Tools
for convenient access
@return [Array<Reviewer::Tool>] collection of all currently enabled tools
# File lib/reviewer/arguments/keywords.rb, line 117 def tools @tools ||= Reviewer.tools end