Class | Rcov::FileStatistics |
In: |
lib/rcov.rb
|
Parent: | Object |
A FileStatistics object associates a filename to:
A FileStatistics object can be therefore be built given the filename, the associated source code, and an array holding execution counts (i.e. how many times each line has been executed).
FileStatistics is relatively intelligent: it handles normal comments, =begin/=end, heredocs, many multiline-expressions… It uses a number of heuristics to determine what is code and what is a comment, and to refine the initial (incomplete) coverage information.
Basic usage is as follows:
sf = FileStatistics.new("foo.rb", ["puts 1", "if true &&", " false", "puts 2", "end"], [1, 1, 0, 0, 0]) sf.num_lines # => 5 sf.num_code_lines # => 5 sf.coverage[2] # => true sf.coverage[3] # => :inferred sf.code_coverage # => 0.6
The array of strings representing the source code and the array of execution counts would normally be obtained from a Rcov::CodeCoverageAnalyzer.
counts | [R] | |
coverage | [R] | |
lines | [R] | |
name | [R] |
Code coverage rate: fraction of lines of code executed, relative to the total amount of lines of code (loc). Returns a float from 0 to 1.0.
Returns true if the given line number corresponds to code, as opposed to a comment (either # or =begin/=end blocks).
Merge code coverage and execution count information. As for code coverage, a line will be considered
Execution counts are just summated on a per-line basis.