reviewer 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.alexignore +1 -0
  3. data/.flayignore +1 -0
  4. data/.github/workflows/main.yml +14 -4
  5. data/.gitignore +5 -0
  6. data/.inch.yml +4 -0
  7. data/.reviewer.example.yml +63 -0
  8. data/.reviewer.future.yml +221 -0
  9. data/.reviewer.yml +140 -0
  10. data/.reviewer_stdout +0 -0
  11. data/.rubocop.yml +20 -0
  12. data/CHANGELOG.md +38 -3
  13. data/Gemfile +2 -4
  14. data/Gemfile.lock +103 -20
  15. data/LICENSE.txt +4 -20
  16. data/README.md +23 -29
  17. data/Rakefile +5 -5
  18. data/bin/console +4 -4
  19. data/exe/fmt +7 -0
  20. data/exe/rvw +7 -0
  21. data/lib/reviewer/arguments/files.rb +94 -0
  22. data/lib/reviewer/arguments/keywords.rb +133 -0
  23. data/lib/reviewer/arguments/tags.rb +71 -0
  24. data/lib/reviewer/arguments.rb +54 -10
  25. data/lib/reviewer/batch.rb +91 -0
  26. data/lib/reviewer/command/string/env.rb +44 -0
  27. data/lib/reviewer/command/string/flags.rb +51 -0
  28. data/lib/reviewer/command/string.rb +66 -0
  29. data/lib/reviewer/command.rb +75 -0
  30. data/lib/reviewer/configuration.rb +32 -7
  31. data/lib/reviewer/conversions.rb +16 -0
  32. data/lib/reviewer/guidance.rb +77 -0
  33. data/lib/reviewer/history.rb +69 -0
  34. data/lib/reviewer/keywords/git/staged.rb +64 -0
  35. data/lib/reviewer/keywords/git.rb +14 -0
  36. data/lib/reviewer/keywords.rb +9 -0
  37. data/lib/reviewer/loader.rb +36 -9
  38. data/lib/reviewer/output/printer.rb +44 -0
  39. data/lib/reviewer/output/scrubber.rb +48 -0
  40. data/lib/reviewer/output/token.rb +85 -0
  41. data/lib/reviewer/output.rb +122 -0
  42. data/lib/reviewer/runner/strategies/captured.rb +157 -0
  43. data/lib/reviewer/runner/strategies/passthrough.rb +63 -0
  44. data/lib/reviewer/runner.rb +131 -0
  45. data/lib/reviewer/shell/result.rb +84 -0
  46. data/lib/reviewer/shell/timer.rb +72 -0
  47. data/lib/reviewer/shell.rb +54 -0
  48. data/lib/reviewer/tool/settings.rb +38 -19
  49. data/lib/reviewer/tool.rb +137 -23
  50. data/lib/reviewer/tools.rb +87 -8
  51. data/lib/reviewer/version.rb +1 -1
  52. data/lib/reviewer.rb +107 -28
  53. data/reviewer.gemspec +34 -19
  54. data/structure.svg +1 -0
  55. metadata +244 -12
  56. data/bin/review +0 -5
  57. data/lib/reviewer/tool/command.rb +0 -78
  58. data/lib/reviewer/tool/env.rb +0 -39
  59. data/lib/reviewer/tool/flags.rb +0 -39
  60. data/lib/reviewer/tool/verbosity.rb +0 -39
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'runner/strategies/captured'
4
+ require_relative 'runner/strategies/passthrough'
5
+
6
+ module Reviewer
7
+ # Wrapper for executng a command and printing the results
8
+ class Runner
9
+ extend Forwardable
10
+
11
+ attr_accessor :strategy
12
+
13
+ attr_reader :command, :shell, :output
14
+
15
+ def_delegators :@command, :tool
16
+ def_delegators :@shell, :result, :timer
17
+ def_delegators :result, :exit_status, :stdout, :stderr, :rerunnable?
18
+
19
+ # Creates a wrapper for running commansd through Reviewer in order to provide a more accessible
20
+ # API for recording execution time and interpreting the results of a command in a more
21
+ # generous way so that non-zero exit statuses can still potentiall be passing.
22
+ # @param tool [Symbol] the key for the desired tool to run
23
+ # @param command_type [Symbol] the key for the type of command to run
24
+ # @param strategy = Strategies::Captured [Runner::Strategies] how to execute and handle the
25
+ # results of the command
26
+ # @param output: Reviewer.output [Review::Output] the output formatter for the results
27
+ #
28
+ # @return [self]
29
+ def initialize(tool, command_type, strategy = Strategies::Captured, output: Reviewer.output)
30
+ @command = Command.new(tool, command_type)
31
+ @strategy = strategy
32
+ @shell = Shell.new
33
+ @output = output
34
+ end
35
+
36
+ def run
37
+ # Show which tool is running
38
+ identify_tool
39
+
40
+ # Use the provided strategy to run the command
41
+ execute_strategy
42
+
43
+ # If it failed, display guidance to help them get back on track
44
+ guidance.show unless success?
45
+
46
+ # Return the exit status generated by the tool as interpreted by the Result
47
+ exit_status
48
+ end
49
+
50
+ def success?
51
+ # Some review tools return a range of non-zero exit statuses and almost never return 0.
52
+ # (`yarn audit` is a good example.) Those tools can be configured to accept a non-zero exit
53
+ # status so they aren't constantly considered to be failing over minor issues.
54
+ #
55
+ # But when other command types (prepare, install, format) are run, they either succeed or they
56
+ # fail. With no shades of gray in those cases, anything other than a 0 is a failure.
57
+ if command.type == :review
58
+ exit_status <= tool.max_exit_status
59
+ else
60
+ exit_status.zero?
61
+ end
62
+ end
63
+
64
+ # Prints the tool name and description to the console as a frame of reference
65
+ #
66
+ # @return [void]
67
+ def identify_tool
68
+ # If there's an existing result, the runner is being re-run, and identifying the tool would
69
+ # be redundant.
70
+ return if result.exists?
71
+
72
+ output.tool_summary(tool)
73
+ end
74
+
75
+ # Runs the relevant strategy to either capture or pass through command output.
76
+ #
77
+ # @return [void]
78
+ def execute_strategy
79
+ # Run the provided strategy
80
+ strategy.new(self).tap do |run_strategy|
81
+ run_strategy.prepare if run_prepare_step?
82
+ run_strategy.run
83
+ end
84
+ end
85
+
86
+ # Determines whether a preparation step should be run before the primary command. If/when the
87
+ # primary command is a `:prepare` command, then it shouldn't run twice. So it skips what would
88
+ # be a superfluous run of the preparation.
89
+ #
90
+ # @return [Boolean] true the primary command is not prepare and the tool needs to be prepare
91
+ def run_prepare_step?
92
+ command.type != :prepare && tool.prepare?
93
+ end
94
+
95
+ # Creates_an instance of the prepare command for a tool
96
+ #
97
+ # @return [Comman] the current tool's prepare command
98
+ def prepare_command
99
+ @prepare_command ||= Command.new(tool, :prepare)
100
+ end
101
+
102
+ # Updates the 'last prepared at' timestamp that Reviewer uses to know if a tool's preparation
103
+ # step is stale and needs to be run again.
104
+ #
105
+ # @return [Time] the timestamp `last_prepared_at` is updated to
106
+ def update_last_prepared_at
107
+ # Touch the `last_prepared_at` timestamp for the tool so it waits before running again.
108
+ tool.last_prepared_at = Time.now
109
+ end
110
+
111
+ # Saves the last 5 elapsed times for the commands used this run by using the raw command as a
112
+ # unique key. This enables the ability to compare times across runs while taking into
113
+ # consideration that different iterations of the command may be running on fewer files. So
114
+ # comparing a full run to the average time for a partial run wouldn't be helpful. By using the
115
+ # raw command string, it will always be apples to apples.
116
+ #
117
+ # @return [void]
118
+ def record_timing
119
+ tool.record_timing(prepare_command, timer.prep)
120
+ tool.record_timing(command, timer.main)
121
+ end
122
+
123
+ # Uses the result of the runner to determine what, if any, guidance to display to help the user
124
+ # get back on track in the event of an unsuccessful run.
125
+ #
126
+ # @return [Guidance] the relevant guidance based on the result of the runner
127
+ def guidance
128
+ @guidance ||= Reviewer::Guidance.new(command: command, result: result, output: output)
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Reviewer
4
+ class Shell
5
+ # Provides a structure interface for the results of running a command
6
+ class Result
7
+ EXIT_STATUS_CODES = {
8
+ success: 0,
9
+ cannot_execute: 126,
10
+ executable_not_found: 127,
11
+ terminated: 130
12
+ }.freeze
13
+
14
+ # Not all command line tools use the 127 exit status when an executable cannot be found, so
15
+ # this provides a home for recognizeable strings in those tools' error messages that we can
16
+ # translate to the appropriate exit status for internal consistency
17
+ STD_ERROR_STRINGS = {
18
+ executable_not_found: "can't find executable"
19
+ }.freeze
20
+
21
+ attr_accessor :stdout, :stderr, :status, :exit_status
22
+
23
+ # An instance of a result from running a local command. Captures the values for `$stdout`,
24
+ # `$stderr`, and the exit status of the command to provide a reliable way of interpreting
25
+ # the results for commands that otherwise use these values inconsistently.
26
+ # @param stdout = nil [String] standard out output from a command
27
+ # @param stderr = nil [String] standard error output from a command
28
+ # @param status = nil [ProcessStatus] an instance of ProcessStatus for a command
29
+ #
30
+ # @example Using with `Open3.capture3`
31
+ # captured_results = Open3.capture3(command)
32
+ # result = Result.new(*captured_results)
33
+ #
34
+ # @return [self]
35
+ def initialize(stdout = nil, stderr = nil, status = nil)
36
+ @stdout = stdout
37
+ @stderr = stderr
38
+ @status = status
39
+ @exit_status = status&.exitstatus
40
+ end
41
+
42
+ def exists?
43
+ [stdout, stderr, exit_status].compact.any?
44
+ end
45
+
46
+ # Determines if re-running a command is entirely futile. Primarily to help when a command
47
+ # fails within a batch and needs to be re-run to show the output
48
+ #
49
+ # @return [Boolean] true if the exit status code is greater than or equal to 126
50
+ def rerunnable?
51
+ exit_status < EXIT_STATUS_CODES[:cannot_execute]
52
+ end
53
+
54
+ # Determines whether a command simply cannot be executed.
55
+ #
56
+ # @return [Boolean] true if the exit sttaus code equals 126
57
+ def cannot_execute?
58
+ exit_status == EXIT_STATUS_CODES[:cannot_execute]
59
+ end
60
+
61
+ # Determines whether the command failed because the executable cannot be found. Since this is
62
+ # an error that can be corrected fairly predictably and easily, it provides the ability to
63
+ # tailor the error guidance to help folks recover
64
+ #
65
+ # @return [Boolean] true if the exit sttaus code is 127 or there's a recognizable equivalent
66
+ # value in the standard error string
67
+ def executable_not_found?
68
+ exit_status == EXIT_STATUS_CODES[:executable_not_found] ||
69
+ stderr&.include?(STD_ERROR_STRINGS[:executable_not_found])
70
+ end
71
+
72
+ # Returns a string representation of the result
73
+ #
74
+ # @return [String] stdout if present, otherwise stderr
75
+ def to_s
76
+ result_string = ''
77
+ result_string += stderr
78
+ result_string += stdout
79
+
80
+ result_string.strip
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Reviewer
6
+ class Shell
7
+ # Provides a structured interface for measuring realtime main while running comamnds
8
+ class Timer
9
+ attr_accessor :prep, :main
10
+
11
+ # A 'Smart' timer that understands preparation time and main time and can easily do the math
12
+ # to help determine what percentage of time was prep. The times can be passed in directly or
13
+ # recorded using the `record_prep` and `record_main` methods
14
+ # @param prep: nil [Float] the amount of time in seconds the preparation command ran
15
+ # @param main: nil [Float] the amount of time in seconds the primary command ran
16
+ #
17
+ # @return [self]
18
+ def initialize(prep: nil, main: nil)
19
+ @prep = prep
20
+ @main = main
21
+ end
22
+
23
+ # Records the execution time for the block and assigns it to the `prep` time
24
+ # @param &block [Block] the commands to be timed
25
+ #
26
+ # @return [Float] the execution time for the preparation
27
+ def record_prep(&block)
28
+ @prep = record(&block)
29
+ end
30
+
31
+ # Records the execution time for the block and assigns it to the `main` time
32
+ # @param &block [Block] the commands to be timed
33
+ #
34
+ # @return [Float] the execution time for the main command
35
+ def record_main(&block)
36
+ @main = record(&block)
37
+ end
38
+
39
+ def prep_seconds
40
+ prep.round(2)
41
+ end
42
+
43
+ def main_seconds
44
+ main.round(2)
45
+ end
46
+
47
+ def total_seconds
48
+ total.round(2)
49
+ end
50
+
51
+ def prep_percent
52
+ return nil unless prepped?
53
+
54
+ (prep / total.to_f * 100).round
55
+ end
56
+
57
+ def total
58
+ [prep, main].compact.sum
59
+ end
60
+
61
+ def prepped?
62
+ !(prep.nil? || main.nil?)
63
+ end
64
+
65
+ private
66
+
67
+ def record(&block)
68
+ Benchmark.realtime(&block)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ require_relative 'shell/result'
6
+ require_relative 'shell/timer'
7
+
8
+ module Reviewer
9
+ # Handles running, timing, and capturing results for a command
10
+ class Shell
11
+ extend Forwardable
12
+
13
+ attr_reader :timer, :result, :captured_results
14
+
15
+ def_delegators :@result, :exit_status
16
+
17
+ # Initializes a Reviewer shell for running and benchmarking commands, and capturing output
18
+ #
19
+ # @return [Shell] a shell instance for running and benchmarking commands
20
+ def initialize
21
+ @timer = Timer.new
22
+ @result = Result.new
23
+ end
24
+
25
+ # Run a command without capturing the output. This ensures the results are displayed realtime
26
+ # if the command was run directly in the shell. So it keeps any color or other formatting that
27
+ # would be stripped out by capturing $stdout as a basic string.
28
+ # @param command [String] the command to run
29
+ #
30
+ # @return [Integer] exit status vaue of 0 when successful or 1 when unsuccessful
31
+ def direct(command)
32
+ command = String(command)
33
+
34
+ result.exit_status = system(command) ? 0 : 1
35
+ end
36
+
37
+ def capture_prep(command)
38
+ timer.record_prep { capture_results(command) }
39
+ end
40
+
41
+ def capture_main(command)
42
+ timer.record_main { capture_results(command) }
43
+ end
44
+
45
+ private
46
+
47
+ def capture_results(command)
48
+ command = String(command)
49
+
50
+ @captured_results = Open3.capture3(command)
51
+ @result = Result.new(*@captured_results)
52
+ end
53
+ end
54
+ end
@@ -1,36 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Converts/casts tool configuration values and provides default values if not set
4
3
  module Reviewer
5
4
  class Tool
5
+ # Converts/casts tool configuration values and provides appropriate default values if not set.
6
6
  class Settings
7
- class MissingReviewCommandError < StandardError; end
8
-
9
- attr_reader :tool, :config
7
+ attr_reader :tool_key, :config
8
+
9
+ alias key tool_key
10
+
11
+ # Creates an instance of settings for retrieving values from the configuration file.
12
+ # @param tool_key [Symbol] the unique identifier for the tool in the config file
13
+ # @param config: nil [Hash] the configuration values to examine for the settings
14
+ #
15
+ # @return [self]
16
+ def initialize(tool_key, config: nil)
17
+ @tool_key = tool_key.to_sym
18
+ @config = config || load_config
19
+ end
10
20
 
11
- def initialize(tool, config: nil)
12
- @tool = tool
13
- @config = config || Reviewer.configuration.tools.fetch(tool.to_sym) { {} }
21
+ def hash
22
+ state.hash
23
+ end
14
24
 
15
- # Ideally, folks would fill out everything, but realistically, the 'review' command is the only required value.
16
- # If the key is missing, or maybe there was a typo, fail right away.
17
- raise MissingReviewCommandError, "'#{name}' does not have a 'review' key under 'commands' in your tools configuration" unless commands.key?(:review)
25
+ def eql?(other)
26
+ self.class == other.class &&
27
+ state == other.state
18
28
  end
29
+ alias :== eql?
19
30
 
20
31
  def disabled?
21
- config.fetch(:disabled) { false }
32
+ config.fetch(:disabled, false)
22
33
  end
23
34
 
24
35
  def enabled?
25
36
  !disabled?
26
37
  end
27
38
 
28
- def key
29
- tool.to_sym
30
- end
31
-
32
39
  def name
33
- config.fetch(:name) { tool.to_s.titleize }
40
+ config.fetch(:name) { tool_key.to_s.capitalize }
34
41
  end
35
42
 
36
43
  def description
@@ -53,16 +60,28 @@ module Reviewer
53
60
  config.fetch(:flags) { {} }
54
61
  end
55
62
 
63
+ # The collection of configured commands for the tool
64
+ #
65
+ # @return [Hash] all of the commands configured for the tool
56
66
  def commands
57
67
  config.fetch(:commands) { {} }
58
68
  end
59
69
 
70
+ # The largest exit status that can still be considered a success for the command
71
+ #
72
+ # @return [Integer] the configured `max_exit_status` for the tool or 0 if one isn't configured
60
73
  def max_exit_status
61
- commands.fetch(:max_exit_status) { 0 }
74
+ commands.fetch(:max_exit_status, 0)
75
+ end
76
+
77
+ protected
78
+
79
+ def state
80
+ config.to_hash
62
81
  end
63
82
 
64
- def quiet_flag
65
- commands.fetch(:quiet_flag) { '' }
83
+ def load_config
84
+ Reviewer.tools.to_h.fetch(key) { {} }
66
85
  end
67
86
  end
68
87
  end
data/lib/reviewer/tool.rb CHANGED
@@ -1,44 +1,158 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/core_ext/string"
4
- require_relative "tool/command"
5
- require_relative "tool/env"
6
- require_relative "tool/flags"
7
- require_relative "tool/settings"
8
- require_relative "tool/verbosity"
9
-
10
- # Provides an instance of a specific tool
3
+ require 'date'
4
+
5
+ require_relative 'tool/settings'
6
+
11
7
  module Reviewer
8
+ # Provides an instance of a specific tool for accessing its settings and run history
12
9
  class Tool
13
- attr_reader :settings
10
+ extend Forwardable
11
+ include Comparable
12
+
13
+ # In general, Reviewer tries to save time where it can. In the case of the "prepare" command
14
+ # used by some tools to retrieve data, it only runs it occasionally in order to save time.
15
+ # This is the default window that it uses to determine if the tool's preparation step should be
16
+ # considered stale and needs to be rerun. Frequent enough that it shouldn't get stale, but
17
+ # infrequent enough that it's not cumbersome.
18
+ SIX_HOURS_IN_SECONDS = 60 * 60 * 6
19
+
20
+ attr_reader :settings, :history
21
+
22
+ def_delegators :@settings,
23
+ :key,
24
+ :name,
25
+ :hash,
26
+ :description,
27
+ :tags,
28
+ :commands,
29
+ :links,
30
+ :enabled?,
31
+ :disabled?,
32
+ :max_exit_status
33
+
34
+ alias to_sym key
35
+ alias to_s name
36
+
37
+ # Create an instance of a tool
38
+ # @param tool_key [Symbol] the key to the tool from the configuration file
39
+ #
40
+ # @return [Tool] an instance of tool for accessing settings information and facts about the tool
41
+ def initialize(tool_key)
42
+ @settings = Settings.new(tool_key)
43
+ end
44
+
45
+ # For determining if the tool should run it's prepration command. It will only be run both if
46
+ # the tool has a preparation command, and the command hasn't been run 6 hours
47
+ #
48
+ # @return [Boolean] true if the tool has a configured `prepare` command that hasn't been run in
49
+ # the last 6 hours
50
+ def prepare?
51
+ preparable? && stale?
52
+ end
53
+
54
+ # Determines whether a tool has a specific command type configured
55
+ # @param command_type [Symbol] one of the available command types defined in Command::TYPES
56
+ #
57
+ # @return [Boolean] true if the command type is configured and not blank
58
+ def command?(command_type)
59
+ commands.key?(command_type) && !commands[command_type].nil?
60
+ end
61
+
62
+ # Determines if the tool can run a `install` command
63
+ #
64
+ # @return [Boolean] true if there is a non-blank `install` command configured
65
+ def installable?
66
+ command?(:install)
67
+ end
14
68
 
15
- def initialize(tool)
16
- @settings = Settings.new(tool)
69
+ # Determines if the tool can run a `prepare` command
70
+ #
71
+ # @return [Boolean] true if there is a non-blank `prepare` command configured
72
+ def preparable?
73
+ command?(:prepare)
17
74
  end
18
75
 
19
- def installation_command(verbosity_level = :no_silence)
20
- command_string(:install, verbosity_level: verbosity_level)
76
+ # Determines if the tool can run a `review` command
77
+ #
78
+ # @return [Boolean] true if there is a non-blank `review` command configured
79
+ def reviewable?
80
+ command?(:review)
21
81
  end
22
82
 
23
- def preparation_command(verbosity_level = :no_silence)
24
- command_string(:prepare, verbosity_level: verbosity_level)
83
+ # Determines if the tool can run a `format` command
84
+ #
85
+ # @return [Boolean] true if there is a non-blank `format` command configured
86
+ def formattable?
87
+ command?(:format)
25
88
  end
26
89
 
27
- def review_command(verbosity_level = :total_silence)
28
- command_string(:review, verbosity_level: verbosity_level)
90
+ # Specifies when the tool last had it's `prepare` command run
91
+ #
92
+ # @return [Time] timestamp of when the `prepare` command was last run
93
+ def last_prepared_at
94
+ date_string = Reviewer.history.get(key, :last_prepared_at)
95
+
96
+ date_string == '' || date_string.nil? ? nil : DateTime.parse(date_string).to_time
97
+ end
98
+
99
+ # Sets the timestamp for when the tool last ran its `prepare` command
100
+ # @param last_prepared_at [DateTime] the value to record for when the `prepare` command last ran
101
+ #
102
+ # @return [DateTime] timestamp of when the `prepare` command was last run
103
+ def last_prepared_at=(last_prepared_at)
104
+ Reviewer.history.set(key, :last_prepared_at, last_prepared_at.to_s)
105
+ end
106
+
107
+ def average_time(command)
108
+ times = get_timing(command)
109
+
110
+ times.any? ? times.sum / times.size : 0
111
+ end
112
+
113
+ def get_timing(command)
114
+ Reviewer.history.get(key, command.raw_string) || []
29
115
  end
30
116
 
31
- def format_command(verbosity_level = :no_silence)
32
- command_string(:format, verbosity_level: verbosity_level)
117
+ def record_timing(command, time)
118
+ return if time.nil?
119
+
120
+ timing = get_timing(command).take(4) << time.round(2)
121
+
122
+ Reviewer.history.set(key, command.raw_string, timing)
33
123
  end
34
124
 
125
+ # Determines whether the `prepare` command was run recently enough
126
+ #
127
+ # @return [Boolean] true if a prepare command exists, a timestamp exists, and it was run more
128
+ # than six hours ago
129
+ def stale?
130
+ return false unless preparable?
35
131
 
36
- private
132
+ last_prepared_at.nil? || last_prepared_at < Time.now - SIX_HOURS_IN_SECONDS
133
+ end
37
134
 
38
- def command_string(command_type, verbosity_level: :no_silence)
39
- cmd = Command.new(command_type, tool_settings: settings, verbosity_level: verbosity_level)
135
+ # Convenience method for determining if a tool has a configured install link
136
+ #
137
+ # @return [Boolean] true if there is an `install` key under links and the value isn't blank
138
+ def install_link?
139
+ links.key?(:install) && !links[:install].nil?
140
+ end
141
+
142
+ # Returns the text for the install link if available
143
+ #
144
+ # @return [String, nil] the link if it exists, nil otherwise
145
+ def install_link
146
+ install_link? ? links.fetch(:install) : nil
147
+ end
40
148
 
41
- cmd.to_s
149
+ # Determines if two tools are equal
150
+ # @param other [Tool] the tool to compare to the current instance
151
+ #
152
+ # @return [Boolean] true if the settings match
153
+ def eql?(other)
154
+ settings == other.settings
42
155
  end
156
+ alias :== eql?
43
157
  end
44
158
  end