covered 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -3
- data/lib/covered/coverage.rb +10 -0
- data/lib/covered/statistics.rb +36 -11
- data/lib/covered/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c4bbf71292213867fe6b7edfd7e35b65eedbbb6bfe1a5f985fadb2535af22ee
|
|
4
|
+
data.tar.gz: 96b6183060c491be6ca61d1e6c5397bae731024b6c67a53852872f49d282db31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 620ad151084106eaabb854b255a571e52613050d1cd44eb6bbe3af86b17c94088dcdd7f82d1e57748a09fa8ea7de41d06b617d03e88ae51a0354bfcfcd7c53b8
|
|
7
|
+
data.tar.gz: cc520d2837f572ecdf76b53bd9c61058b948cf84036ef988ae17f6b6bbba8e2822191e826486fd5583e2c16c8a04640cbcd632829b4198193aba13fa35e1ce6d
|
checksums.yaml.gz.sig
CHANGED
data/lib/covered/coverage.rb
CHANGED
|
@@ -51,6 +51,16 @@ module Covered
|
|
|
51
51
|
@annotations = annotations
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
# Initialize a copy of this coverage object.
|
|
55
|
+
# @parameter other [Covered::Coverage] The coverage object to copy.
|
|
56
|
+
def initialize_copy(other)
|
|
57
|
+
super
|
|
58
|
+
|
|
59
|
+
@source = other.source.dup
|
|
60
|
+
@counts = other.counts.dup
|
|
61
|
+
@annotations = other.annotations.transform_values(&:dup)
|
|
62
|
+
end
|
|
63
|
+
|
|
54
64
|
# @attribute [Covered::Source] The covered source metadata.
|
|
55
65
|
attr_accessor :source
|
|
56
66
|
|
data/lib/covered/statistics.rb
CHANGED
|
@@ -28,6 +28,17 @@ module Covered
|
|
|
28
28
|
class Aggregate
|
|
29
29
|
include Ratio
|
|
30
30
|
|
|
31
|
+
# Build aggregate statistics from coverage objects.
|
|
32
|
+
# @parameter coverages [Enumerable(Covered::Coverage)] The coverage objects to summarize.
|
|
33
|
+
# @returns [Covered::Statistics::Aggregate] The aggregate statistics.
|
|
34
|
+
def self.for(coverages)
|
|
35
|
+
self.new.tap do |aggregate|
|
|
36
|
+
coverages.each do |coverage|
|
|
37
|
+
aggregate << coverage
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
31
42
|
# Initialize empty aggregate statistics.
|
|
32
43
|
def initialize
|
|
33
44
|
@count = 0
|
|
@@ -35,8 +46,7 @@ module Covered
|
|
|
35
46
|
@executed_count = 0
|
|
36
47
|
end
|
|
37
48
|
|
|
38
|
-
#
|
|
39
|
-
# @returns [Integer] The number of coverage objects added.
|
|
49
|
+
# @attribute [Integer] The total number of coverage instances added.
|
|
40
50
|
attr :count
|
|
41
51
|
|
|
42
52
|
# The number of lines which could have been executed.
|
|
@@ -67,22 +77,28 @@ module Covered
|
|
|
67
77
|
|
|
68
78
|
# Add coverage to these aggregate statistics.
|
|
69
79
|
# @parameter coverage [Covered::Coverage] The coverage object to add.
|
|
80
|
+
# @returns [Covered::Statistics::Aggregate] This aggregate.
|
|
70
81
|
def << coverage
|
|
71
82
|
@count += 1
|
|
72
83
|
|
|
73
84
|
@executable_count += coverage.executable_count
|
|
74
85
|
@executed_count += coverage.executed_count
|
|
86
|
+
|
|
87
|
+
self
|
|
75
88
|
end
|
|
76
89
|
end
|
|
77
90
|
|
|
78
91
|
# Initialize empty coverage statistics.
|
|
79
92
|
def initialize
|
|
80
|
-
@total =
|
|
93
|
+
@total = nil
|
|
81
94
|
@paths = Hash.new
|
|
82
95
|
end
|
|
83
96
|
|
|
84
|
-
#
|
|
85
|
-
|
|
97
|
+
# The total aggregate statistics.
|
|
98
|
+
# @returns [Covered::Statistics::Aggregate] The total aggregate statistics.
|
|
99
|
+
def total
|
|
100
|
+
@total ||= Aggregate.for(@paths.values)
|
|
101
|
+
end
|
|
86
102
|
|
|
87
103
|
# @attribute [Hash(String, Covered::Coverage)] Coverage statistics indexed by path.
|
|
88
104
|
attr :paths
|
|
@@ -96,20 +112,29 @@ module Covered
|
|
|
96
112
|
# The total number of executable lines.
|
|
97
113
|
# @returns [Integer] The total executable line count.
|
|
98
114
|
def executable_count
|
|
99
|
-
|
|
115
|
+
total.executable_count
|
|
100
116
|
end
|
|
101
117
|
|
|
102
118
|
# The total number of executed lines.
|
|
103
119
|
# @returns [Integer] The total executed line count.
|
|
104
120
|
def executed_count
|
|
105
|
-
|
|
121
|
+
total.executed_count
|
|
106
122
|
end
|
|
107
123
|
|
|
108
124
|
# Add coverage to these statistics.
|
|
109
125
|
# @parameter coverage [Covered::Coverage] The coverage object to add.
|
|
110
126
|
def << coverage
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
if current = @paths[coverage.path]
|
|
128
|
+
current.merge!(coverage)
|
|
129
|
+
|
|
130
|
+
@total = nil
|
|
131
|
+
else
|
|
132
|
+
coverage = @paths[coverage.path] = coverage.dup
|
|
133
|
+
|
|
134
|
+
@total << coverage if @total
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
self
|
|
113
138
|
end
|
|
114
139
|
|
|
115
140
|
# Get coverage for the given path.
|
|
@@ -124,7 +149,7 @@ module Covered
|
|
|
124
149
|
def as_json
|
|
125
150
|
{
|
|
126
151
|
total: total.as_json,
|
|
127
|
-
paths:
|
|
152
|
+
paths: paths.map{|path, coverage| [path, coverage.as_json]}.to_h,
|
|
128
153
|
}
|
|
129
154
|
end
|
|
130
155
|
|
|
@@ -151,7 +176,7 @@ module Covered
|
|
|
151
176
|
# Print a human-readable coverage summary.
|
|
152
177
|
# @parameter output [IO] The output stream.
|
|
153
178
|
def print(output)
|
|
154
|
-
output.puts "#{count} files checked; #{
|
|
179
|
+
output.puts "#{count} files checked; #{total.executed_count}/#{total.executable_count} lines executed; #{total.percentage.to_f.round(2)}% covered."
|
|
155
180
|
|
|
156
181
|
if self.complete?
|
|
157
182
|
output.puts "🧘 #{COMPLETE.sample}"
|
data/lib/covered/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|