class GCOVTOOLS::Line

Attributes

count[R]
number[R]
text[R]

Public Class Methods

closing_brace_patterns() click to toggle source
# File lib/line.rb, line 22
def self.closing_brace_patterns
  [
   /^}[ ;]*$/, # brace followed by any number of spaces and semi-colons (methods/classes/closures)
   /^}[ ;]*\/\/.*$/, # brace + [semicolon(s)] + inline comment (e.g. end of class/method)
  ]
end
new(number, count, text) click to toggle source
# File lib/line.rb, line 8
def initialize number, count, text
  @number = number
  @count = count
  @text = text
end
parse(line) click to toggle source
# File lib/line.rb, line 29
def self.parse line
  match = /^[ ]*([0-9]+|-|#####):[ ]*([0-9]+):(.*)/.match(line)
  fail "Invalid line: #{line}" unless match.to_a.count == 4
  count,number,text = match.to_a[1..3]
  number = number.to_i
  count = case count.strip
          when "-" then :none
          when "#####" then :missed
          else count.to_i
          end
 
  count = :none if count == :missed and Line.closing_brace_patterns.select{|re| re.match(text.strip) }.count > 0
  GCOVTOOLS::Line.new number,count,text
end

Public Instance Methods

merge(other) click to toggle source
# File lib/line.rb, line 56
def merge other
  result = self.dup
  result.merge! other
  result
end
merge!(other) click to toggle source
# File lib/line.rb, line 44
def merge! other
  if other.count.is_a? Integer and @count.is_a? Integer
    @count += other.count
  elsif other.count.is_a? Integer
    @count = other.count
  elsif @count.is_a? Integer
    nil
  elsif other.count == :missed or @count == :missed
    @count = :missed
  end
end
state() click to toggle source
# File lib/line.rb, line 14
def state
  case @count
  when :missed then :missed
  when :none then :none
  else :exec
  end
end