covered 0.15.2 → 0.16.1

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: 112c85633150c4f05435b29a2867a51a711a9f216fdbe850c0356b0371ab4e49
4
- data.tar.gz: 2efa0d7a7d07ca3125237c55b4e1d34fd4835e5f9d963344f1c7b4b9405d37eb
3
+ metadata.gz: b81262b921d5bf71ca05d985d28c806967de336642687e6541507ac55f9eb5ce
4
+ data.tar.gz: 4afab1fb523ee9403e6a70c9fc84cb301152f32a8c273367fac79c994cd5e7b8
5
5
  SHA512:
6
- metadata.gz: 054c6dca966431d180da1ff4e98afadea19400ec2ea28a2f7b4a3096ae6affdcc0082f939bb612cc3440861b4e1bd55e1b88dc03b7a93205ec19d2e3935fb5fd
7
- data.tar.gz: f9ea6aacbb0993749c4e808f09c8b6bcccfa5d7f6c640fcdf83a79a7432fffd893008ccb6aed9314801f1c79446dcb82bdfc919e55c1564ca5691920a6371073
6
+ metadata.gz: a59901d7eaca8f7494879453b9df6e024ebe97fa039d5be732edc51c8f9acd258db76a2bc35f4b4a500d69bab68a184da3b70c63a375c5f2f7670c8aeb0e8f15
7
+ data.tar.gz: 2092189dd748a544104b63597018b31913b1ec4bbea477a2907cdd01fb8dfcd5dbe842b5d341d58601e9fba62e5a2e2e2077fec572a5375dc98343ca8b6758d6
checksums.yaml.gz.sig CHANGED
Binary file
@@ -22,5 +22,7 @@ def validate(paths: nil, minimum: 1.0)
22
22
  statistics << coverage
23
23
  end
24
24
 
25
+ statistics.print($stderr)
26
+
25
27
  statistics.validate!(minimum)
26
28
  end
data/lib/covered/cache.rb CHANGED
@@ -32,7 +32,7 @@ module Covered
32
32
 
33
33
  def mark(path, lineno, count = 1)
34
34
  if @marks
35
- @marks << path << lineno << count
35
+ @marks.push(path, lineno, count)
36
36
  else
37
37
  super
38
38
  end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative 'policy'
24
+
25
+ module Covered
26
+ class Config
27
+ PATH = "config/covered.rb"
28
+
29
+ def self.path(root)
30
+ path = ::File.join(root, PATH)
31
+
32
+ if ::File.exist?(path)
33
+ return path
34
+ end
35
+ end
36
+
37
+ def self.load(root: Dir.pwd, coverage: ENV['COVERAGE'])
38
+ return nil unless coverage
39
+
40
+ derived = Class.new(self)
41
+
42
+ if path = self.path(root)
43
+ config = Module.new
44
+ config.module_eval(::File.read(path), path)
45
+ derived.prepend(config)
46
+ end
47
+
48
+ return derived.new(root, coverage)
49
+ end
50
+
51
+ def initialize(root, coverage)
52
+ @root = root
53
+ @coverage = coverage
54
+ @policy = nil
55
+ end
56
+
57
+ def policy
58
+ @policy ||= Policy.new.tap{|policy| make_policy(policy)}.freeze
59
+ end
60
+
61
+ def enable
62
+ policy.enable
63
+ end
64
+
65
+ def disable
66
+ policy.disable
67
+ end
68
+
69
+ def flush
70
+ policy.flush
71
+ end
72
+
73
+ def call(output)
74
+ policy.call(output)
75
+ end
76
+
77
+ # Override this method to implement your own policy.
78
+ def make_policy(policy)
79
+ policy.cache!
80
+
81
+ # Only files in the root would be tracked:
82
+ policy.root(@root)
83
+
84
+ # We will ignore any files in the test or spec directory:
85
+ policy.skip(/^.*\/(test|spec|vendor|config)\//)
86
+
87
+ # We will include all files under lib, even if they aren't loaded:
88
+ policy.include("lib/**/*.rb")
89
+
90
+ policy.persist!
91
+
92
+ policy.source
93
+
94
+ policy.reports!(@coverage)
95
+ end
96
+ end
97
+ end
@@ -19,10 +19,11 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require_relative 'policy'
22
- require_relative 'policy/default'
23
22
 
24
23
  require 'minitest'
25
24
 
25
+ $covered = Covered::Config.load
26
+
26
27
  module Covered
27
28
  module Minitest
28
29
  def run(*)
@@ -33,7 +34,7 @@ module Covered
33
34
  end
34
35
  end
35
36
 
36
- if ENV['COVERAGE']
37
+ if $covered
37
38
  class << Minitest
38
39
  prepend Covered::Minitest
39
40
  end
@@ -26,16 +26,6 @@ require_relative "cache"
26
26
  require_relative "persist"
27
27
 
28
28
  module Covered
29
- def self.policy(&block)
30
- policy = Policy.new
31
-
32
- policy.instance_eval(&block)
33
-
34
- policy.freeze
35
-
36
- return policy
37
- end
38
-
39
29
  class Policy < Wrapper
40
30
  def initialize
41
31
  super(Files.new)
@@ -132,7 +122,7 @@ module Covered
132
122
  end
133
123
  end
134
124
 
135
- def reports!(coverage = ENV['COVERAGE'])
125
+ def reports!(coverage)
136
126
  if coverage
137
127
  names = coverage.split(',')
138
128
 
data/lib/covered/rspec.rb CHANGED
@@ -18,11 +18,12 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'policy'
22
- require_relative 'policy/default'
21
+ require_relative 'config'
23
22
 
24
23
  require 'rspec/core/formatters'
25
24
 
25
+ $covered = Covered::Config.load
26
+
26
27
  module Covered
27
28
  module RSpec
28
29
  class Formatter
@@ -56,7 +57,7 @@ module Covered
56
57
  end
57
58
  end
58
59
 
59
- if ENV['COVERAGE']
60
+ if $covered
60
61
  RSpec::Core::Configuration.prepend(Covered::RSpec::Policy)
61
62
 
62
63
  RSpec.configure do |config|
@@ -68,8 +68,17 @@ module Covered
68
68
 
69
69
  attr :paths
70
70
 
71
+ EXECUTABLE = {
72
+ send: true,
73
+ yield: true,
74
+ return: true,
75
+ lvar: true,
76
+ ivar: true,
77
+ def: true
78
+ }
79
+
71
80
  def executable?(node)
72
- node.type == :send || node.type == :yield
81
+ EXECUTABLE[node.type]
73
82
  end
74
83
 
75
84
  def ignore?(node)
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Covered
22
- VERSION = "0.15.2"
22
+ VERSION = "0.16.1"
23
23
  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.15.2
4
+ version: 0.16.1
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-13 00:00:00.000000000 Z
42
+ date: 2022-06-14 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: async-rest
@@ -163,6 +163,7 @@ files:
163
163
  - lib/covered.rb
164
164
  - lib/covered/cache.rb
165
165
  - lib/covered/capture.rb
166
+ - lib/covered/config.rb
166
167
  - lib/covered/coverage.rb
167
168
  - lib/covered/coveralls.rb
168
169
  - lib/covered/files.rb
@@ -170,7 +171,6 @@ files:
170
171
  - lib/covered/minitest.rb
171
172
  - lib/covered/persist.rb
172
173
  - lib/covered/policy.rb
173
- - lib/covered/policy/default.rb
174
174
  - lib/covered/rspec.rb
175
175
  - lib/covered/source.rb
176
176
  - lib/covered/statistics.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,44 +0,0 @@
1
- # Copyright, 2019, 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 '../policy'
22
-
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
44
- end