Class: SimpleCov::LinesClassifier
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/simplecov/lines_classifier.rb | 
Overview
Classifies whether lines are relevant for code coverage analysis. Comments & whitespace lines, and :nocov: token blocks, are considered not relevant.
Constant Summary
- 
    COMMENT_LINE =
    
 # File 'lib/simplecov/lines_classifier.rb', line 12/^\s*#/.freeze 
- 
    NOT_RELEVANT =
    
 # File 'lib/simplecov/lines_classifier.rb', line 9nil
- 
    RELEVANT =
    
 # File 'lib/simplecov/lines_classifier.rb', line 80
- 
    WHITESPACE_LINE =
    
 # File 'lib/simplecov/lines_classifier.rb', line 11/^\s*$/.freeze 
- 
    WHITESPACE_OR_COMMENT_LINE =
    
 # File 'lib/simplecov/lines_classifier.rb', line 13Regexp.union(WHITESPACE_LINE, COMMENT_LINE) 
Class Method Summary
Instance Method Summary
Class Method Details
.no_cov_line
[ GitHub ]# File 'lib/simplecov/lines_classifier.rb', line 15
def self.no_cov_line /^(\s*)#(\s*)(:#{SimpleCov.nocov_token}:)/o end
    .no_cov_line?(line)  ⇒ Boolean 
  
# File 'lib/simplecov/lines_classifier.rb', line 19
def self.no_cov_line?(line) no_cov_line.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false end
    .whitespace_line?(line)  ⇒ Boolean 
  
# File 'lib/simplecov/lines_classifier.rb', line 26
def self.whitespace_line?(line) WHITESPACE_OR_COMMENT_LINE.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false end
Instance Method Details
#classify(lines)
[ GitHub ]# File 'lib/simplecov/lines_classifier.rb', line 33
def classify(lines) skipping = false lines.map do |line| if self.class.no_cov_line?(line) skipping = !skipping NOT_RELEVANT elsif skipping || self.class.whitespace_line?(line) NOT_RELEVANT else RELEVANT end end end