Class: Reviewer::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/batch.rb

Overview

Provides a structure for running commands for a given set of tools

Defined Under Namespace

Classes: UnrecognizedCommandError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_type, tools, output: Reviewer.output) ⇒ self

Generates an instance of Batch for running multiple tools together

Parameters:

  • command_type (Symbol)

    the type of command to run for each tool.

  • tools (Array<Tool>)

    the tools to run the commands for

  • output: (defaults to: Reviewer.output)

    Reviewer.output [Output] the output channel to print results to



16
17
18
19
20
21
# File 'lib/reviewer/batch.rb', line 16

def initialize(command_type, tools, output: Reviewer.output)
  @command_type = command_type
  @tools = tools
  @output  = output
  @results = {}
end

Instance Attribute Details

#command_typeObject (readonly)

Returns the value of attribute command_type.



8
9
10
# File 'lib/reviewer/batch.rb', line 8

def command_type
  @command_type
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/reviewer/batch.rb', line 8

def output
  @output
end

#resultsObject (readonly)

Returns the value of attribute results.



8
9
10
# File 'lib/reviewer/batch.rb', line 8

def results
  @results
end

#toolsObject (readonly)

Returns the value of attribute tools.



8
9
10
# File 'lib/reviewer/batch.rb', line 8

def tools
  @tools
end

Instance Method Details

#runResults

Iterates over the tools in the batch to successfully run the commands. Also times the entire

batch in order to provide a total execution time.

Returns:

  • (Results)

    the results summary for all commands run



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/reviewer/batch.rb', line 27

def run
  benchmark_batch do
    matching_tools.each do |tool|
      # Create and execute a runner for the given tool, command type, and strategy
      runner = Runner.new(tool, command_type, strategy)
      runner.run

      # Record the exit status for this tool
      record_exit_status(runner)

      # If the tool fails, stop running other tools
      break unless runner.success?
    end
  end

  results
end