minitest-cc 0.2.0 → 1.0.0
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
- data/lib/minitest/cc/file_array.rb +23 -11
- data/lib/minitest/cc/file_coverage.rb +9 -9
- data/lib/minitest/cc/version.rb +1 -1
- data/lib/minitest/cc.rb +8 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3057b7420f4eb647e697cfa3e2fb9a0d9586665dfe577b1fc5f5552af8b7b6e8
|
4
|
+
data.tar.gz: 57173dbf03435603affd8e078faf958cbe53b227ffbc13e7989e37647e3e17f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72bb82508786ca90a692c3812d33a78147282fc2667fda08274feb43ba3dbd88759b079e46237aecdc2a572043de207e2a307f5b71e06ed6e6c814f491e62529
|
7
|
+
data.tar.gz: '08d491e36ad409f5b0e827b7631ee55d2aa7f1236fee5631a326bb279ffeecea36019517c04b1a669cdbaf3ae48d42314098d6dc9759a5445735256b65505239'
|
@@ -6,35 +6,47 @@ module Minitest
|
|
6
6
|
class FileArray < Array
|
7
7
|
##
|
8
8
|
# Calculate the lines average of the self array
|
9
|
-
# @return [
|
9
|
+
# @return [Float] percent of lines executed
|
10
10
|
def lines_average
|
11
11
|
lines = reduce(0) { |sum, v| sum + v.lines.to_i }
|
12
|
+
|
13
|
+
return 0.0 if lines.zero?
|
14
|
+
|
12
15
|
lines_executed = reduce(0) { |sum, v| sum + v.lines_executed.to_i }
|
13
|
-
lines_executed * 100 / lines
|
14
|
-
rescue ZeroDivisionError
|
15
|
-
0
|
16
|
+
lines_executed * 100.0 / lines
|
16
17
|
end
|
17
18
|
|
18
19
|
##
|
19
20
|
# Calculate the branches average of the self array
|
20
|
-
# @return [
|
21
|
+
# @return [Float] percent of branches executed
|
21
22
|
def branches_average
|
22
23
|
branches = reduce(0) { |sum, v| sum + v.branches.to_i }
|
24
|
+
|
25
|
+
return 0.0 if branches.zero?
|
26
|
+
|
23
27
|
branches_executed = reduce(0) { |sum, v| sum + v.branches_executed.to_i }
|
24
|
-
branches_executed * 100 / branches
|
25
|
-
rescue ZeroDivisionError
|
26
|
-
0
|
28
|
+
branches_executed * 100.0 / branches
|
27
29
|
end
|
28
30
|
|
29
31
|
##
|
30
32
|
# Calculate the methods average of the self array
|
31
|
-
# @return [
|
33
|
+
# @return [Float] percent of methods executed
|
32
34
|
def methods_average
|
33
35
|
methods = reduce(0) { |sum, v| sum + v.methods.to_i }
|
36
|
+
|
37
|
+
return 0.0 if methods.zero?
|
38
|
+
|
34
39
|
methods_executed = reduce(0) { |sum, v| sum + v.methods_executed.to_i }
|
35
|
-
methods_executed * 100 / methods
|
40
|
+
methods_executed * 100.0 / methods
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Calculate total average of coverage
|
45
|
+
# @return [Float] percent of coverage
|
46
|
+
def total_coverage_percent
|
47
|
+
(lines_average + branches_average + methods_average) / 3
|
36
48
|
rescue ZeroDivisionError
|
37
|
-
0
|
49
|
+
0.0
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
@@ -154,9 +154,9 @@ module Minitest
|
|
154
154
|
# @return [Integer] percent of coverage. executed lines / total lines
|
155
155
|
#
|
156
156
|
def lines_percent
|
157
|
-
|
158
|
-
|
159
|
-
0
|
157
|
+
return 0.0 if lines.zero?
|
158
|
+
|
159
|
+
lines_executed * 100.0 / lines
|
160
160
|
end
|
161
161
|
|
162
162
|
##
|
@@ -164,9 +164,9 @@ module Minitest
|
|
164
164
|
# @return [Integer] percent of coverage. executed branches / total branches
|
165
165
|
#
|
166
166
|
def branches_percent
|
167
|
-
|
168
|
-
|
169
|
-
0
|
167
|
+
return 0.0 if branches.zero?
|
168
|
+
|
169
|
+
branches_executed * 100.0 / branches
|
170
170
|
end
|
171
171
|
|
172
172
|
##
|
@@ -174,9 +174,9 @@ module Minitest
|
|
174
174
|
# @return [Integer] percent of coverage. executed methods / total methods
|
175
175
|
#
|
176
176
|
def methods_percent
|
177
|
-
|
178
|
-
|
179
|
-
0
|
177
|
+
return 0.0 if methods.zero?
|
178
|
+
|
179
|
+
methods_executed * 100.0 / methods
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
data/lib/minitest/cc/version.rb
CHANGED
data/lib/minitest/cc.rb
CHANGED
@@ -69,6 +69,7 @@ module Minitest
|
|
69
69
|
else
|
70
70
|
puts resume
|
71
71
|
end
|
72
|
+
puts "\nAverage: #{@files.total_coverage_percent.round(2).to_s_color}%"
|
72
73
|
end
|
73
74
|
|
74
75
|
##
|
@@ -97,9 +98,9 @@ module Minitest
|
|
97
98
|
# @return [String] String with averages
|
98
99
|
def resume
|
99
100
|
str = ''
|
100
|
-
str += "
|
101
|
-
str += "
|
102
|
-
str += "
|
101
|
+
str += "Lines: #{@files.lines_average.round(2).to_s_color}%\t" if coverage_mode.include? :lines
|
102
|
+
str += "Branches: #{@files.branches_average.round(2).to_s_color}%\t" if coverage_mode.include? :branches
|
103
|
+
str += "Methods: #{@files.methods_average.round(2).to_s_color}%\t" if coverage_mode.include? :methods
|
103
104
|
str
|
104
105
|
end
|
105
106
|
end
|
@@ -120,14 +121,14 @@ class String # :nodoc:
|
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
123
|
-
class
|
124
|
+
class Float # :nodoc:
|
124
125
|
def to_s_color
|
125
126
|
case self
|
126
|
-
when 1..33
|
127
|
+
when 1.0..33.0
|
127
128
|
to_s.red
|
128
|
-
when
|
129
|
+
when 33.1..66.0
|
129
130
|
to_s.yellow
|
130
|
-
when
|
131
|
+
when 66.1..100.0
|
131
132
|
to_s.green
|
132
133
|
else
|
133
134
|
to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Plugin for minitest. It provides minimal information about code coverage. '
|
14
14
|
email:
|