Class: Reviewer::Tool::Settings
- Inherits:
-
Object
- Object
- Reviewer::Tool::Settings
- Defined in:
- lib/reviewer/tool/settings.rb
Overview
Converts/casts tool configuration values and provides appropriate default values if not set.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#tool_key ⇒ Object
(also: #key)
readonly
Returns the value of attribute tool_key.
Instance Method Summary collapse
-
#commands ⇒ Hash
The collection of configured commands for the tool.
-
#description ⇒ String
The human-readable description of what the tool does.
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#env ⇒ Hash
The environment variables to set when running the tool.
-
#eql?(other) ⇒ Boolean
(also: #==)
Compares two settings instances for equality based on their configuration.
-
#files_command(command_type) ⇒ String?
Returns the file-scoped command override for a given command type.
-
#files_flag ⇒ String
The CLI flag used to pass files to the tool (e.g., '--files').
-
#files_pattern ⇒ String?
The glob pattern used to filter which files this tool should process.
-
#files_separator ⇒ String
The separator used to join multiple file paths in the command.
-
#flags ⇒ Hash
The CLI flags to pass to the tool's review command.
-
#hash ⇒ Integer
Returns a hash code for comparing settings instances.
-
#initialize(tool_key, config:) ⇒ Settings
constructor
Creates an instance of settings for retrieving values from the configuration file.
-
#links ⇒ Hash
The collection of reference links for the tool (home, install, usage, etc.).
-
#map_to_tests ⇒ String?
The test framework to use for mapping source files to test files.
-
#max_exit_status ⇒ Integer
The largest exit status that can still be considered a success for the command.
-
#name ⇒ String
The human-readable name of the tool.
- #skip_in_batch? ⇒ Boolean
-
#summary_label ⇒ String?
The label template for displaying the extracted summary detail.
-
#summary_pattern ⇒ String?
The regex pattern for extracting a summary detail from tool output.
- #supports_files? ⇒ Boolean
-
#tags ⇒ Array<String>
The tags used to categorize and filter the tool.
Constructor Details
#initialize(tool_key, config:) ⇒ Settings
Creates an instance of settings for retrieving values from the configuration file
16 17 18 19 |
# File 'lib/reviewer/tool/settings.rb', line 16 def initialize(tool_key, config:) @tool_key = tool_key.to_sym @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/reviewer/tool/settings.rb', line 7 def config @config end |
#tool_key ⇒ Object (readonly) Also known as: key
Returns the value of attribute tool_key.
7 8 9 |
# File 'lib/reviewer/tool/settings.rb', line 7 def tool_key @tool_key end |
Instance Method Details
#commands ⇒ Hash
The collection of configured commands for the tool
120 |
# File 'lib/reviewer/tool/settings.rb', line 120 def commands = config.fetch(:commands) { {} } |
#description ⇒ String
The human-readable description of what the tool does
54 |
# File 'lib/reviewer/tool/settings.rb', line 54 def description = config.fetch(:description) { "(No description provided for '#{name}')" } |
#disabled? ⇒ Boolean
43 |
# File 'lib/reviewer/tool/settings.rb', line 43 def disabled? = skip_in_batch? |
#enabled? ⇒ Boolean
44 |
# File 'lib/reviewer/tool/settings.rb', line 44 def enabled? = !skip_in_batch? |
#env ⇒ Hash
The environment variables to set when running the tool
69 |
# File 'lib/reviewer/tool/settings.rb', line 69 def env = config.fetch(:env) { {} } |
#eql?(other) ⇒ Boolean Also known as: ==
Compares two settings instances for equality based on their configuration
29 30 31 32 |
# File 'lib/reviewer/tool/settings.rb', line 29 def eql?(other) self.class == other.class && state == other.state end |
#files_command(command_type) ⇒ String?
Returns the file-scoped command override for a given command type. When configured, this command replaces the standard command when files are passed.
115 |
# File 'lib/reviewer/tool/settings.rb', line 115 def files_command(command_type) = config.dig(:files, command_type) |
#files_flag ⇒ String
The CLI flag used to pass files to the tool (e.g., '--files')
79 |
# File 'lib/reviewer/tool/settings.rb', line 79 def files_flag = config.dig(:files, :flag) || '' |
#files_pattern ⇒ String?
The glob pattern used to filter which files this tool should process. Patterns without a slash match basenames; patterns with a slash match repository-relative paths and support brace alternatives.
91 |
# File 'lib/reviewer/tool/settings.rb', line 91 def files_pattern = config.dig(:files, :pattern) |
#files_separator ⇒ String
The separator used to join multiple file paths in the command
84 |
# File 'lib/reviewer/tool/settings.rb', line 84 def files_separator = config.dig(:files, :separator) || ' ' |
#flags ⇒ Hash
The CLI flags to pass to the tool's review command
74 |
# File 'lib/reviewer/tool/settings.rb', line 74 def flags = config.fetch(:flags) { {} } |
#hash ⇒ Integer
Returns a hash code for comparing settings instances
24 |
# File 'lib/reviewer/tool/settings.rb', line 24 def hash = state.hash |
#links ⇒ Hash
The collection of reference links for the tool (home, install, usage, etc.)
64 |
# File 'lib/reviewer/tool/settings.rb', line 64 def links = config.fetch(:links) { {} } |
#map_to_tests ⇒ String?
The test framework to use for mapping source files to test files
96 |
# File 'lib/reviewer/tool/settings.rb', line 96 def map_to_tests = config.dig(:files, :map_to_tests) |
#max_exit_status ⇒ Integer
The largest exit status that can still be considered a success for the command
125 |
# File 'lib/reviewer/tool/settings.rb', line 125 def max_exit_status = commands.fetch(:max_exit_status) { 0 } |
#name ⇒ String
The human-readable name of the tool
49 |
# File 'lib/reviewer/tool/settings.rb', line 49 def name = config.fetch(:name) { tool_key.to_s.capitalize } |
#skip_in_batch? ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/reviewer/tool/settings.rb', line 35 def skip_in_batch? if config.key?(:skip_in_batch) config.fetch(:skip_in_batch) { false } else config.fetch(:disabled) { false } end end |
#summary_label ⇒ String?
The label template for displaying the extracted summary detail
108 |
# File 'lib/reviewer/tool/settings.rb', line 108 def summary_label = config.dig(:summary, :label) |
#summary_pattern ⇒ String?
The regex pattern for extracting a summary detail from tool output
103 |
# File 'lib/reviewer/tool/settings.rb', line 103 def summary_pattern = config.dig(:summary, :pattern) |
#supports_files? ⇒ Boolean
98 |
# File 'lib/reviewer/tool/settings.rb', line 98 def supports_files? = config.key?(:files) |
#tags ⇒ Array<String>
The tags used to categorize and filter the tool
59 |
# File 'lib/reviewer/tool/settings.rb', line 59 def = config.fetch(:tags) { [] } |