123456789_123456789_123456789_123456789_123456789_

Class: SimpleCov::ExitCodes::MinimumCoverageByFileCheck

Relationships & Source Files
Inherits: Object
Defined in: lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(result, minimum_coverage_by_file) ⇒ MinimumCoverageByFileCheck

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 6

def initialize(result, minimum_coverage_by_file)
  @result = result
  @minimum_coverage_by_file = minimum_coverage_by_file
end

Instance Attribute Details

#failing?Boolean (readonly)

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 11

def failing?
  violations.any?
end

Instance Method Details

#exit_code

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 27

def exit_code
  SimpleCov::ExitCodes::MINIMUM_COVERAGE
end

#report

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 15

def report
  violations.each do |violation|
    $stderr.printf(
      "%<criterion>s coverage by file (%<covered>.2f%%) is below the expected minimum coverage (%<minimum_coverage>.2f%%) in %<filename>s.\n",
      covered: violation.fetch(:actual),
      minimum_coverage: violation.fetch(:expected),
      criterion: violation.fetch(:criterion).capitalize,
      filename: violation.fetch(:project_filename)
    )
  end
end

#violations (private)

[ GitHub ]

  
# File 'lib/simplecov/exit_codes/minimum_coverage_by_file_check.rb', line 33

def violations
  @violations ||= SimpleCov::CoverageViolations.minimum_by_file(@result, @minimum_coverage_by_file)
end