Class: Emma::Report

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

Defined Under Namespace

Classes: Coverage, Coverages, Node

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, uri = nil) ⇒ Report

Returns a new instance of Report.



7
8
9
10
# File 'lib/emma/report.rb', line 7

def initialize(doc, uri = nil)
  @doc = doc
  @uri = uri
end

Class Method Details

.from(file) ⇒ Object



3
4
5
# File 'lib/emma/report.rb', line 3

def self.from(file)
  new Nokogiri::XML.parse(File.read(file)), file
end

Instance Method Details

#dataObject



26
27
28
29
# File 'lib/emma/report.rb', line 26

def data
  el = @doc.css("report data all").first or raise Error, "invalid coverage report (missing report data)"
  Node.new el
end

#inspectObject



12
13
14
# File 'lib/emma/report.rb', line 12

def inspect
  '#<%s:0x%x %s>' % [self.class, hash, "uri=#{@uri}"]
end

#statsObject



16
17
18
19
20
21
22
23
24
# File 'lib/emma/report.rb', line 16

def stats
  @stats ||= {
    :packages     => fetch_stat('packages'),
    :classes      => fetch_stat("classes"),
    :methods      => fetch_stat("methods"),
    :source_files => fetch_stat("srcfiles"),
    :source_lines => fetch_stat("srclines"),
  }
end