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 ⇒ Object
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
- #env ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #flags ⇒ Object
- #hash ⇒ Object
-
#initialize(tool_key, config: nil) ⇒ self
constructor
Creates an instance of settings for retrieving values from the configuration file.
- #links ⇒ Object
-
#max_exit_status ⇒ Integer
The largest exit status that can still be considered a success for the command.
- #name ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize(tool_key, config: nil) ⇒ self
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: nil) @tool_key = tool_key.to_sym @config = config || load_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
66 67 68 |
# File 'lib/reviewer/tool/settings.rb', line 66 def commands config.fetch(:commands) { {} } end |
#description ⇒ Object
43 44 45 |
# File 'lib/reviewer/tool/settings.rb', line 43 def description config.fetch(:description) { "(No description provided for '#{name}')" } end |
#disabled? ⇒ Boolean
31 32 33 |
# File 'lib/reviewer/tool/settings.rb', line 31 def disabled? config.fetch(:disabled, false) end |
#enabled? ⇒ Boolean
35 36 37 |
# File 'lib/reviewer/tool/settings.rb', line 35 def enabled? !disabled? end |
#env ⇒ Object
55 56 57 |
# File 'lib/reviewer/tool/settings.rb', line 55 def env config.fetch(:env) { {} } end |
#eql?(other) ⇒ Boolean Also known as: ==
25 26 27 28 |
# File 'lib/reviewer/tool/settings.rb', line 25 def eql?(other) self.class == other.class && state == other.state end |
#flags ⇒ Object
59 60 61 |
# File 'lib/reviewer/tool/settings.rb', line 59 def flags config.fetch(:flags) { {} } end |
#hash ⇒ Object
21 22 23 |
# File 'lib/reviewer/tool/settings.rb', line 21 def hash state.hash end |
#links ⇒ Object
51 52 53 |
# File 'lib/reviewer/tool/settings.rb', line 51 def links config.fetch(:links) { {} } end |
#max_exit_status ⇒ Integer
The largest exit status that can still be considered a success for the command
73 74 75 |
# File 'lib/reviewer/tool/settings.rb', line 73 def max_exit_status commands.fetch(:max_exit_status, 0) end |
#name ⇒ Object
39 40 41 |
# File 'lib/reviewer/tool/settings.rb', line 39 def name config.fetch(:name) { tool_key.to_s.capitalize } end |
#tags ⇒ Object
47 48 49 |
# File 'lib/reviewer/tool/settings.rb', line 47 def config.fetch(:tags) { [] } end |