Class: DeepCover::FlagCommentAssociator

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_cover/flag_comment_associator.rb

Overview

A processor which computes which lines to be considered flagged with the given lookup

Instance Method Summary collapse

Constructor Details

#initialize(covered_code, lookup = 'nocov') ⇒ FlagCommentAssociator

Returns a new instance of FlagCommentAssociator.

Parameters:

  • ast (DeepCover::RootNode)
  • comments (Array(Parser::Source::Comment))


12
13
14
15
16
# File 'lib/deep_cover/flag_comment_associator.rb', line 12

def initialize(covered_code, lookup = 'nocov')
  @covered_code = covered_code
  @lookup       = /^#[\s#*-]*#{lookup}[\s#*-]*$/
  @ranges       = nil
end

Instance Method Details

#include?(range) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/deep_cover/flag_comment_associator.rb', line 18

def include?(range)
  return false unless (exp = range.expression)
  lineno = exp.line
  ranges.any? { |r| r.cover? lineno }
end

#rangesObject



24
25
26
# File 'lib/deep_cover/flag_comment_associator.rb', line 24

def ranges
  @ranges ||= compute_ranges
end