Class: SimpleCov::SourceFile::SkipChunks

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/source_file/skip_chunks.rb

Overview

The line ranges excluded from a SourceFile's coverage per criterion. Two sources contribute: the deprecated nocov block toggle, and the SimpleCov::Directive block directives, which can be scoped per criterion.

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, src) ⇒ SkipChunks

Returns a new instance of SkipChunks.



14
15
16
17
# File 'lib/simplecov/source_file/skip_chunks.rb', line 14

def initialize(filename, src)
  @filename = filename
  @src = src
end

Class Attribute Details

.nocov_warnedObject (readonly)

Returns the value of attribute nocov_warned.



11
12
13
# File 'lib/simplecov/source_file/skip_chunks.rb', line 11

def nocov_warned
  @nocov_warned
end

Instance Method Details

#chunks_for(criterion) ⇒ Object

Every criterion honors the deprecated all-criteria nocov chunks plus its own per-criterion directive ranges, methods included: they carry a source range, and nocov has always meant "exclude everything here". The ranges are 1-based line numbers, so consumers subtract 1 to index into the zero-based lines array.



24
25
26
# File 'lib/simplecov/source_file/skip_chunks.rb', line 24

def chunks_for(criterion)
  nocov_chunks + directive_chunks.fetch(criterion)
end

#directive_chunksObject



32
33
34
# File 'lib/simplecov/source_file/skip_chunks.rb', line 32

def directive_chunks
  @directive_chunks ||= Directive.disabled_ranges(ruby_lines)
end

#nocov_chunksObject



28
29
30
# File 'lib/simplecov/source_file/skip_chunks.rb', line 28

def nocov_chunks
  @nocov_chunks ||= build_nocov_chunks
end