Class: Report::Cobertura

Inherits:
Object
  • Object
show all
Defined in:
lib/report/cobertura.rb

Instance Method Summary collapse

Instance Method Details

#translate(doc) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/report/cobertura.rb', line 2

def translate(doc)
  doc
    .xpath("//class")
    .reduce({}) do |acc, file|
      acc[file.attr("filename")] ||= {}
      acc[file.attr("filename")][:lines] = file
        .xpath("lines/line")
        .reduce({}) do |bcc, line|
          line_num = line.attr("number").to_i
          bcc[line_num] = {
            hits: line.attr("hits").to_i,
            type: line.attr("branch") == "true" ? :condition : :statement
          }
          bcc
        end
      acc
    end
end