Class: Covered::Statistics::Aggregate

Inherits:
Object
  • Object
show all
Includes:
Ratio
Defined in:
lib/covered/statistics.rb

Overview

Aggregate coverage totals.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ratio

#complete?, #percentage, #ratio

Constructor Details

#initializeAggregate

Initialize empty aggregate statistics.



32
33
34
35
36
# File 'lib/covered/statistics.rb', line 32

def initialize
	@count = 0
	@executable_count = 0
	@executed_count = 0
end

Instance Attribute Details

#countObject (readonly)

Total number of files added.



40
41
42
# File 'lib/covered/statistics.rb', line 40

def count
  @count
end

#executable_countObject (readonly)

The number of lines which could have been executed.



44
45
46
# File 'lib/covered/statistics.rb', line 44

def executable_count
  @executable_count
end

#executed_countObject (readonly)

The number of lines that were executed.



48
49
50
# File 'lib/covered/statistics.rb', line 48

def executed_count
  @executed_count
end

Instance Method Details

#<<(coverage) ⇒ Object

Add coverage to these aggregate statistics.



70
71
72
73
74
75
# File 'lib/covered/statistics.rb', line 70

def << coverage
	@count += 1
	
	@executable_count += coverage.executable_count
	@executed_count += coverage.executed_count
end

#as_jsonObject

A JSON-compatible representation of these aggregate statistics.



52
53
54
55
56
57
58
59
# File 'lib/covered/statistics.rb', line 52

def as_json
	{
		count: count,
		executable_count: executable_count,
		executed_count: executed_count,
		percentage: percentage.to_f.round(2),
	}
end

#to_json(options) ⇒ Object

Convert these aggregate statistics to JSON.



64
65
66
# File 'lib/covered/statistics.rb', line 64

def to_json(options)
	as_json.to_json(options)
end