Class: Reviewer::Tools
- Inherits:
-
Object
- Object
- Reviewer::Tools
- Includes:
- Enumerable
- Defined in:
- lib/reviewer/tools.rb
Overview
Provides convenient access to subsets of configured tools based on provided arguments, configured tools, their enabled/disabled status, and more.
Instance Method Summary collapse
-
#all ⇒ Array<Tool>
(also: #to_a)
Provides a collection of all configured tools instantiated as Tool instances.
-
#current ⇒ Array<Tool>
Uses the full context of a run to provide the filtered subset of tools to use.
-
#enabled ⇒ Array<Tool>
Provides a collection of all enabled tools instantiated as Tool instances.
-
#initialize(tags: nil, tool_names: nil) ⇒ Reviewer::Tools
constructor
Provides an instance to work with for knowing which tools to run in a given context.
-
#specified ⇒ Array<Tool>
Provides a collection of all explicitly-specified-via-command-line tools as Tool instances.
-
#tagged ⇒ Array<Tool>
Provides a collection of all tagged-via-command-line tools as Tool instances.
-
#to_h ⇒ Hash
(also: #inspect)
The current state of all available configured tools regardless of whether they are disabled.
Constructor Details
permalink #initialize(tags: nil, tool_names: nil) ⇒ Reviewer::Tools
Provides an instance to work with for knowing which tools to run in a given context.
14 15 16 17 |
# File 'lib/reviewer/tools.rb', line 14 def initialize(tags: nil, tool_names: nil) @tags = @tool_names = tool_names end |
Instance Method Details
permalink #all ⇒ Array<Tool> Also known as: to_a
Provides a collection of all configured tools instantiated as Tool instances
30 31 32 |
# File 'lib/reviewer/tools.rb', line 30 def all configured.keys.map { |tool_name| Tool.new(tool_name) } end |
permalink #current ⇒ Array<Tool>
Uses the full context of a run to provide the filtered subset of tools to use. It takes into consideration: tagged tools, explicitly-specified tools, configuration (enabled/disabled), and any other relevant details that should influence whether a specific tool should be run as part of the current batch being executed.
62 63 64 |
# File 'lib/reviewer/tools.rb', line 62 def current subset? ? (specified + tagged).uniq : enabled end |
permalink #enabled ⇒ Array<Tool>
Provides a collection of all enabled tools instantiated as Tool instances
38 39 40 |
# File 'lib/reviewer/tools.rb', line 38 def enabled @enabled ||= all.keep_if(&:enabled?) end |
permalink #specified ⇒ Array<Tool>
Provides a collection of all explicitly-specified-via-command-line tools as Tool instances
45 46 47 |
# File 'lib/reviewer/tools.rb', line 45 def specified all.keep_if { |tool| named?(tool) } end |
permalink #tagged ⇒ Array<Tool>
Provides a collection of all tagged-via-command-line tools as Tool instances
52 53 54 |
# File 'lib/reviewer/tools.rb', line 52 def tagged enabled.keep_if { |tool| tagged?(tool) } end |
permalink #to_h ⇒ Hash Also known as: inspect
The current state of all available configured tools regardless of whether they are disabled
22 23 24 |
# File 'lib/reviewer/tools.rb', line 22 def to_h configured end |