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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d29a2eaa9fe3d3c29ea8a111f6375b193e81fc38b7edd2a33df00c47ede4e46
4
- data.tar.gz: 1625f3a42082d69c7b4f47b8b639f51f07ccfe32d27efd2bcb5cd630b49360cb
3
+ metadata.gz: 0c4bbf71292213867fe6b7edfd7e35b65eedbbb6bfe1a5f985fadb2535af22ee
4
+ data.tar.gz: 96b6183060c491be6ca61d1e6c5397bae731024b6c67a53852872f49d282db31
5
5
  SHA512:
6
- metadata.gz: 1a61d788de7508e8e7d7179d11e61ffb898d7c422ff75d452433db10ce4b9b01002f7384fc4bf3558413c6648690a722f07dd240894eb914a44b080a8a961a11
7
- data.tar.gz: 57defb22ee94b826c68af5869faadba29a0b0a0ec32a524b61e2d0b8b5805740f3cee29c43ad4736d7de90de40e0e08b66f99dfe099511c5769780e2dca60f48
6
+ metadata.gz: 620ad151084106eaabb854b255a571e52613050d1cd44eb6bbe3af86b17c94088dcdd7f82d1e57748a09fa8ea7de41d06b617d03e88ae51a0354bfcfcd7c53b8
7
+ data.tar.gz: cc520d2837f572ecdf76b53bd9c61058b948cf84036ef988ae17f6b6bbba8e2822191e826486fd5583e2c16c8a04640cbcd632829b4198193aba13fa35e1ce6d
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1 @@
1
- ����%fq��c��3���c��;�J#3;�@Z����E<����-�o��~�GY�\
2
- ]=�vH���J�ws��z
3
- ����_��tx���Gl�ɦ@��:-W�vzNiۜ0�۲���{!��%&Z_��TX��gΐ���t��
1
+ ��^SJ3�&�L��6x�$kY�w�����b
@@ -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
 
@@ -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
- # Total number of files added.
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 = Aggregate.new
93
+ @total = nil
81
94
  @paths = Hash.new
82
95
  end
83
96
 
84
- # @attribute [Covered::Statistics::Aggregate] The total aggregate statistics.
85
- attr :total
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
- @total.executable_count
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
- @total.executed_count
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
- @total << coverage
112
- (@paths[coverage.path] ||= coverage.empty).merge!(coverage)
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: @paths.map{|path, coverage| [path, coverage.as_json]}.to_h,
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; #{@total.executed_count}/#{@total.executable_count} lines executed; #{@total.percentage.to_f.round(2)}% covered."
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}"
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Covered
8
- VERSION = "0.29.0"
8
+ VERSION = "0.29.1"
9
9
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: covered
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file