covered 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6ce67ae80be9650cde586f9bb8e0496dfebcd2ad7b8176714657cad29cd1eac
4
- data.tar.gz: fa0475934c2c8b95e383ce494c69264f74fb29d7a31f33c2218459e71e7b747d
3
+ metadata.gz: 21a316a4045662e72cde0fa4d4c7fc433597cbb25790965fb3f0eaa341f994bb
4
+ data.tar.gz: af7e1f193caa3ca359ee1e9dabc61019accf5ab3ca24758271937add2b93f8bc
5
5
  SHA512:
6
- metadata.gz: 5cecc1f2ab8fc64c0003734a7e98acba98ad25310ae28be596b21f4230dbf856922b4f495428587353ace8bf568edae6d82ae1051f2a5150ee415b3f6b9107fe
7
- data.tar.gz: 13cffc32f6884dda4911caba487d583b95bcf3f5830b5322674749ba308b839d8ad72b52a1c75dfe42fda533b0c02c55ab15638d11065386a89aed0a70d0327e
6
+ metadata.gz: cc6b308b9360bbd6db4180e92cc00fb1af462492fffc59d6c0b6b45a00f8f388a06d13e5b4d235e2fc74eea9950be34fac291111e0a1b096e98c5673acfd5948
7
+ data.tar.gz: 361693de63a9e20e8dd1181ffac6a27d0bf1e3b7c19828f3e5a8fd762a38917e8fd8268d2922116ed1026cab131836ed9300321e3f256623f05176313a5beaba
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,65 @@
1
+ # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'wrapper'
22
+
23
+ require 'coverage'
24
+
25
+ module Covered
26
+ class Cache < Wrapper
27
+ def initialize(output)
28
+ super(output)
29
+
30
+ @marks = nil
31
+ end
32
+
33
+ def mark(path, lineno, count = 1)
34
+ if @marks
35
+ @marks << path << lineno << count
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ def enable
42
+ @marks = []
43
+
44
+ super
45
+ end
46
+
47
+ def flush
48
+ if @marks
49
+ @marks.each_slice(3) do |path, lineno, count|
50
+ @output.mark(path, lineno, count)
51
+ end
52
+
53
+ @marks = nil
54
+ end
55
+
56
+ super
57
+ end
58
+
59
+ def disable
60
+ super
61
+
62
+ flush
63
+ end
64
+ end
65
+ end
@@ -59,35 +59,6 @@ module Covered
59
59
  end
60
60
  end
61
61
 
62
- class Cache < Wrapper
63
- def initialize(output)
64
- super(output)
65
- @marks = []
66
- end
67
-
68
- def mark(path, lineno, count = 1)
69
- @marks << path << lineno << count
70
- end
71
-
72
- def enable
73
- super
74
- end
75
-
76
- def flush
77
- @marks.each_slice(3) do |path, lineno, count|
78
- @output.mark(path, lineno, count)
79
- end
80
-
81
- @marks.clear
82
- end
83
-
84
- def disable
85
- super
86
-
87
- flush
88
- end
89
- end
90
-
91
62
  # class Capture < Wrapper
92
63
  # def enable
93
64
  # super
@@ -23,6 +23,7 @@ require_relative 'wrapper'
23
23
  require 'msgpack'
24
24
  require 'time'
25
25
  require 'set'
26
+ require 'console'
26
27
 
27
28
  module Covered
28
29
  class Persist < Wrapper
@@ -32,7 +33,6 @@ module Covered
32
33
  super(output)
33
34
 
34
35
  @path = path
35
-
36
36
  @touched = Set.new
37
37
  end
38
38
 
@@ -66,6 +66,8 @@ module Covered
66
66
  File.open(@path, "rb") do |file|
67
67
  file.flock(File::LOCK_SH)
68
68
 
69
+ Console.logger.debug(self) {"Loading from #{@path}..."}
70
+
69
71
  make_unpacker(file).each(&self.method(:apply))
70
72
  end
71
73
  end
@@ -75,6 +77,8 @@ module Covered
75
77
  File.open(@path, "wb") do |file|
76
78
  file.flock(File::LOCK_EX)
77
79
 
80
+ Console.logger.debug(self) {"Saving to #{@path}..."}
81
+
78
82
  packer = make_packer(file)
79
83
 
80
84
  self.each do |coverage|
@@ -87,7 +91,7 @@ module Covered
87
91
 
88
92
  def mark(file, line, count)
89
93
  @touched << file
90
-
94
+
91
95
  super
92
96
  end
93
97
 
@@ -97,6 +101,12 @@ module Covered
97
101
  load!
98
102
  end
99
103
 
104
+ def flush
105
+ load!
106
+
107
+ super
108
+ end
109
+
100
110
  def disable
101
111
  super
102
112
 
@@ -20,21 +20,25 @@
20
20
 
21
21
  require_relative '../policy'
22
22
 
23
- $covered = Covered.policy do
24
- cache!
25
-
26
- # Only files in the root would be tracked:
27
- root(Dir.pwd)
28
-
29
- # We will ignore any files in the test or spec directory:
30
- skip(/^.*\/(test|spec|vendor)\//)
31
-
32
- # We will include all files under lib, even if they aren't loaded:
33
- include("lib/**/*.rb")
34
-
35
- persist!
36
-
37
- source
38
-
39
- reports!
23
+ if File.exist?("config/coverage.rb")
24
+ load("config/coverage.rb")
25
+ else
26
+ $covered = Covered.policy do
27
+ cache!
28
+
29
+ # Only files in the root would be tracked:
30
+ root(Dir.pwd)
31
+
32
+ # We will ignore any files in the test or spec directory:
33
+ skip(/^.*\/(test|spec|vendor)\//)
34
+
35
+ # We will include all files under lib, even if they aren't loaded:
36
+ include("lib/**/*.rb")
37
+
38
+ persist!
39
+
40
+ source
41
+
42
+ reports!
43
+ end
40
44
  end
@@ -22,6 +22,7 @@ require_relative "summary"
22
22
  require_relative "files"
23
23
  require_relative "source"
24
24
  require_relative "capture"
25
+ require_relative "cache"
25
26
  require_relative "persist"
26
27
 
27
28
  module Covered
@@ -42,6 +43,8 @@ module Covered
42
43
  @reports = []
43
44
  end
44
45
 
46
+ attr :output
47
+
45
48
  def freeze
46
49
  return self if frozen?
47
50
 
@@ -91,6 +94,10 @@ module Covered
91
94
  capture.disable
92
95
  end
93
96
 
97
+ def flush
98
+ @output.flush
99
+ end
100
+
94
101
  attr :reports
95
102
 
96
103
  class Autoload
@@ -22,6 +22,9 @@ require_relative 'wrapper'
22
22
  require_relative 'coverage'
23
23
 
24
24
  module Covered
25
+ class CoverageError < StandardError
26
+ end
27
+
25
28
  class Statistics < Wrapper
26
29
  def initialize
27
30
  @count = 0
@@ -51,5 +54,11 @@ module Covered
51
54
 
52
55
  # Could output funny message here, especially for 100% coverage.
53
56
  end
57
+
58
+ def validate!(minimum = 1.0)
59
+ if self.ratio < minimum
60
+ raise CoverageError, "Coverage of #{self.percentage.to_f.round(2)}% is less than required minimum of #{(minimum * 100.0).round(2)}%!"
61
+ end
62
+ end
54
63
  end
55
64
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Covered
22
- VERSION = "0.14.2"
22
+ VERSION = "0.15.0"
23
23
  end
@@ -26,6 +26,9 @@ module Covered
26
26
  def disable
27
27
  end
28
28
 
29
+ def flush
30
+ end
31
+
29
32
  def accept?(path)
30
33
  true
31
34
  end
@@ -60,6 +63,10 @@ module Covered
60
63
  @output.disable
61
64
  end
62
65
 
66
+ def flush
67
+ @output.flush
68
+ end
69
+
63
70
  def accept?(path)
64
71
  @output.accept?(path)
65
72
  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.14.2
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -39,7 +39,7 @@ cert_chain:
39
39
  RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
40
40
  HiLJ8VOFx6w=
41
41
  -----END CERTIFICATE-----
42
- date: 2022-06-11 00:00:00.000000000 Z
42
+ date: 2022-06-13 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: async-rest
@@ -169,6 +169,7 @@ files:
169
169
  - examples/coverage/test.rb
170
170
  - examples/coverage/tracepoint.rb
171
171
  - lib/covered.rb
172
+ - lib/covered/cache.rb
172
173
  - lib/covered/capture.rb
173
174
  - lib/covered/coverage.rb
174
175
  - lib/covered/coveralls.rb
metadata.gz.sig CHANGED
@@ -1,4 +1,4 @@
1
- �*4^\^�U�Lx'�y��ö�����C�APb������dL���h�햓��}�_�l���� ��M!dZ��M�l)�&�F}I[��Ҧ祖cs��ۿ�G?q0a
2
- Eq��D����%֙q��Y��� �YD����>X��,P[��G�������i1� N\~���eL;� 2����� (����"�����s1IY�����[�)M"�ua�r,���x��wO`6_���C��I���emMj�6�9��ƘEIb
3
- H��D9��Z0}Y@
4
- ��g��>�,6ޱ�lcaMK�/v���Kn�i�
1
+ ������j1����|���M�&E|��5�ٵ��R��w(G�ak��A01�c�
2
+ N&i ���UMv̮ �L��>P`�ONٓ=�����eG�f�w_v6xv�AD�gP7fɛ�.��E�߅oSOM�ᚍ���BT\M��г�bRq?X����Η2x<\���r~
3
+ �\������0TW'W;il�K�"� |��L�+�0�\L҄bE�}�e�7�<z�С�G�=M�{�e�i�WD��Z��ʤk����,����G�~m_¢��rWLVi�����"��?����J���5�rY����C��f}� ��+����-�пk�M�孆
4
+ }`�aב�