Class: Quality::QualityChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/quality/quality_checker.rb

Overview

Runs a quality-checking, command, checks it agaist the existing number of violations for that command, and decreases that number if possible, or outputs data if the number of violations increased.

Instance Method Summary collapse

Constructor Details

#initialize(cmd, command_options, output_dir, verbose, minimum_threshold, logger: STDOUT, count_file: File, count_io: IO, command_output_processor_class: Quality::CommandOutputProcessor, count_dir: Dir, process_class: Process) ⇒ QualityChecker

Returns a new instance of QualityChecker.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/quality/quality_checker.rb', line 13

def initialize(cmd, command_options, output_dir, verbose,
               minimum_threshold,
               logger: STDOUT,
               count_file: File,
               count_io: IO,
               command_output_processor_class:
                 Quality::CommandOutputProcessor,
               count_dir: Dir,
               process_class: Process)
  @minimum_threshold = minimum_threshold
  @count_file = count_file
  @count_io = count_io
  @command_output_processor_class = command_output_processor_class
  @logger = logger
  @count_dir = count_dir
  @cmd = cmd
  @command_options = command_options
  @verbose = verbose
  @count_dir.mkdir(output_dir) unless @count_file.exists?(output_dir)
  @threshold = HighWaterMark::Threshold.new(cmd,
                                            count_io: count_io,
                                            count_file: count_file,
                                            output_dir: output_dir)
  @process_class = process_class
end

Instance Method Details

#execute(&count_violations_on_line) ⇒ Object



39
40
41
42
43
44
# File 'lib/quality/quality_checker.rb', line 39

def execute(&count_violations_on_line)
  processor, exit_status = process_command(&count_violations_on_line)
  @violations = processor.violations
  check_exit_status(exit_status)
  ratchet_violations
end