class Reviewer::Tool::Settings
Converts/casts tool configuration values and provides default values if not set.
Attributes
config[R]
key[R]
tool_key[R]
Public Class Methods
new(tool_key, config: nil)
click to toggle source
# File lib/reviewer/tool/settings.rb, line 11 def initialize(tool_key, config: nil) @tool_key = tool_key.to_sym @config = config || load_config end
Public Instance Methods
commands()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 58 def commands config.fetch(:commands) { {} } end
description()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 38 def description config.fetch(:description) { "(No description provided for '#{name}')" } end
disabled?()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 26 def disabled? config.fetch(:disabled, false) end
enabled?()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 30 def enabled? !disabled? end
env()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 50 def env config.fetch(:env) { {} } end
eql?(other)
click to toggle source
# File lib/reviewer/tool/settings.rb, line 20 def eql?(other) self.class == other.class && state == other.state end
Also aliased as: ==
flags()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 54 def flags config.fetch(:flags) { {} } end
hash()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 16 def hash state.hash end
links()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 46 def links config.fetch(:links) { {} } end
max_exit_status()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 62 def max_exit_status commands.fetch(:max_exit_status, 0) end
name()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 34 def name config.fetch(:name) { tool_key.to_s.capitalize } end
quiet_option()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 66 def quiet_option commands.fetch(:quiet_option, '') end
Protected Instance Methods
load_config()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 76 def load_config Reviewer.tools.to_h.fetch(key) { {} } end
state()
click to toggle source
# File lib/reviewer/tool/settings.rb, line 72 def state config.to_hash end