covered 0.10.3 → 0.10.4
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/covered.gemspec +1 -0
- data/lib/covered/files.rb +8 -27
- data/lib/covered/persist.rb +134 -0
- data/lib/covered/policy/default.rb +2 -0
- data/lib/covered/policy.rb +5 -0
- data/lib/covered/version.rb +1 -1
- data/lib/covered/wrapper.rb +63 -18
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42eca672ae3b6b6589c0022ce5de6b610134c9eb3cf9e4edf3b1fb530e6101ab
|
4
|
+
data.tar.gz: 558c12dade107d324740f9dfdcc59c125ca0c847779f502f4901c9fb202de72a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fafd5d915b3e1c3e9f43b568e4564eab02a5049ab65b667bdd39a1ed25294c2a1ddb7d1e424e6b6433ff0d1163d5687a30b731fe6a614bfcb2f40cd25f2c34
|
7
|
+
data.tar.gz: df90259692dfa61889afce1eda933fed4d37c3974dcc9675bcfa0f91e6dac0fba8c0b87fd7ee1b667157c409e4f058dfde6c8dff1d5f1aecd34826477495b80a
|
data/covered.gemspec
CHANGED
data/lib/covered/files.rb
CHANGED
@@ -19,13 +19,14 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
require_relative 'coverage'
|
22
|
+
require_relative 'wrapper'
|
22
23
|
|
23
24
|
require 'set'
|
24
25
|
|
25
26
|
module Covered
|
26
|
-
class Files <
|
27
|
-
def initialize(
|
28
|
-
super
|
27
|
+
class Files < Base
|
28
|
+
def initialize(*)
|
29
|
+
super
|
29
30
|
|
30
31
|
@paths = {}
|
31
32
|
end
|
@@ -88,26 +89,6 @@ module Covered
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
class Filter < Wrapper
|
92
|
-
def accept?(path)
|
93
|
-
true
|
94
|
-
end
|
95
|
-
|
96
|
-
def mark(path, lineno, value)
|
97
|
-
super if accept?(path)
|
98
|
-
end
|
99
|
-
|
100
|
-
def each(&block)
|
101
|
-
super do |coverage|
|
102
|
-
if accept?(coverage.path)
|
103
|
-
yield coverage
|
104
|
-
else
|
105
|
-
puts "Skipping #{coverage.path} #{self.class}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
92
|
class Skip < Filter
|
112
93
|
def initialize(output, pattern)
|
113
94
|
super(output)
|
@@ -119,11 +100,11 @@ module Covered
|
|
119
100
|
|
120
101
|
if Regexp.instance_methods.include? :match?
|
121
102
|
# This is better as it doesn't allocate a MatchData instance which is essentially useless.
|
122
|
-
def
|
103
|
+
def match? path
|
123
104
|
!@pattern.match?(path)
|
124
105
|
end
|
125
106
|
else
|
126
|
-
def
|
107
|
+
def match? path
|
127
108
|
!(@pattern =~ path)
|
128
109
|
end
|
129
110
|
end
|
@@ -138,7 +119,7 @@ module Covered
|
|
138
119
|
|
139
120
|
attr :pattern
|
140
121
|
|
141
|
-
def
|
122
|
+
def match?(path)
|
142
123
|
@pattern === path
|
143
124
|
end
|
144
125
|
end
|
@@ -164,7 +145,7 @@ module Covered
|
|
164
145
|
end
|
165
146
|
end
|
166
147
|
|
167
|
-
def
|
148
|
+
def match?(path)
|
168
149
|
path.start_with?(@path)
|
169
150
|
end
|
170
151
|
end
|
@@ -0,0 +1,134 @@
|
|
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 'msgpack'
|
24
|
+
require 'time'
|
25
|
+
require 'set'
|
26
|
+
|
27
|
+
module Covered
|
28
|
+
class Persist < Wrapper
|
29
|
+
def initialize(output, path = ".covered.msgpack")
|
30
|
+
super(output)
|
31
|
+
|
32
|
+
@path = path
|
33
|
+
|
34
|
+
@touched = Set.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def apply(record)
|
38
|
+
# The file must still exist:
|
39
|
+
return unless path = expand_path(record[:path])
|
40
|
+
return unless File.exist? path
|
41
|
+
|
42
|
+
# If the file has been modified since... we can't use the coverage.
|
43
|
+
return unless mtime = record[:mtime]
|
44
|
+
return if File.mtime(path).to_f > record[:mtime]
|
45
|
+
|
46
|
+
record[:coverage].each_with_index do |count, index|
|
47
|
+
@output.mark(path, index, count) if count
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def serialize(coverage)
|
52
|
+
{
|
53
|
+
# We want to use relative paths so that moving the repo won't break everything:
|
54
|
+
path: relative_path(coverage.path),
|
55
|
+
coverage: coverage.counts,
|
56
|
+
mtime: File.mtime(coverage.path).to_f,
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def load!(path = @path)
|
61
|
+
return unless File.exist?(@path)
|
62
|
+
|
63
|
+
# Load existing coverage information and mark all files:
|
64
|
+
File.open(@path, "r") do |file|
|
65
|
+
file.flock(File::LOCK_SH)
|
66
|
+
|
67
|
+
make_unpacker(file).each(&self.method(:apply))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def save!(path = @path)
|
72
|
+
# Dump all coverage:
|
73
|
+
File.open(@path, "w") do |file|
|
74
|
+
file.flock(File::LOCK_EX)
|
75
|
+
|
76
|
+
packer = make_packer(file)
|
77
|
+
|
78
|
+
self.each do |coverage|
|
79
|
+
packer.write(serialize(coverage))
|
80
|
+
end
|
81
|
+
|
82
|
+
packer.flush
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def mark(file, line, count)
|
87
|
+
@touched << file
|
88
|
+
|
89
|
+
super
|
90
|
+
end
|
91
|
+
|
92
|
+
def enable
|
93
|
+
super
|
94
|
+
|
95
|
+
load!
|
96
|
+
end
|
97
|
+
|
98
|
+
def disable
|
99
|
+
super
|
100
|
+
|
101
|
+
# @touched.each do |path|
|
102
|
+
# if @output.accept?(path)
|
103
|
+
# puts "Updated #{path} coverage."
|
104
|
+
# end
|
105
|
+
# end
|
106
|
+
|
107
|
+
save!
|
108
|
+
end
|
109
|
+
|
110
|
+
# def each
|
111
|
+
# super do |coverage|
|
112
|
+
# if @touched.include?(coverage.path)
|
113
|
+
# yield coverage
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
|
118
|
+
def make_packer(io)
|
119
|
+
packer = MessagePack::Packer.new(io)
|
120
|
+
packer.register_type(0x00, Symbol, :to_msgpack_ext)
|
121
|
+
packer.register_type(0x01, Time) {|object| object.to_s}
|
122
|
+
|
123
|
+
return packer
|
124
|
+
end
|
125
|
+
|
126
|
+
def make_unpacker(io)
|
127
|
+
unpacker = MessagePack::Unpacker.new(io)
|
128
|
+
unpacker.register_type(0x00, Symbol, :from_msgpack_ext)
|
129
|
+
unpacker.register_type(0x01, Time, :parse)
|
130
|
+
|
131
|
+
return unpacker
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/lib/covered/policy.rb
CHANGED
@@ -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 "persist"
|
25
26
|
|
26
27
|
module Covered
|
27
28
|
def self.policy(&block)
|
@@ -74,6 +75,10 @@ module Covered
|
|
74
75
|
@output = Cache.new(@output)
|
75
76
|
end
|
76
77
|
|
78
|
+
def persist!
|
79
|
+
@output = Persist.new(@output)
|
80
|
+
end
|
81
|
+
|
77
82
|
def capture
|
78
83
|
@capture ||= Capture.new(@output)
|
79
84
|
end
|
data/lib/covered/version.rb
CHANGED
data/lib/covered/wrapper.rb
CHANGED
@@ -19,50 +19,95 @@
|
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
21
|
module Covered
|
22
|
-
class
|
23
|
-
|
22
|
+
class Base
|
23
|
+
def enable
|
24
|
+
end
|
25
|
+
|
26
|
+
def disable
|
27
|
+
end
|
28
|
+
|
29
|
+
def accept?(path)
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def mark(path, lineno, value)
|
34
|
+
end
|
24
35
|
|
25
|
-
def
|
36
|
+
def each
|
37
|
+
end
|
38
|
+
|
39
|
+
def relative_path(path)
|
40
|
+
path
|
41
|
+
end
|
42
|
+
|
43
|
+
def expand_path(path)
|
44
|
+
path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Wrapper < Base
|
49
|
+
def initialize(output = Base.new)
|
26
50
|
@output = output
|
27
51
|
end
|
28
52
|
|
29
53
|
attr :output
|
30
54
|
|
31
55
|
def mark(path, lineno, value)
|
32
|
-
@output.mark(path, lineno, value)
|
56
|
+
@output.mark(path, lineno, value)
|
33
57
|
end
|
34
58
|
|
35
59
|
def enable
|
36
|
-
@output.enable
|
60
|
+
@output.enable
|
37
61
|
end
|
38
62
|
|
39
63
|
def disable
|
40
|
-
@output.disable
|
64
|
+
@output.disable
|
65
|
+
end
|
66
|
+
|
67
|
+
def accept?(path)
|
68
|
+
@output.accept?(path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def mark(path, lineno, value)
|
72
|
+
@output.mark(path, lineno, value)
|
41
73
|
end
|
42
74
|
|
43
75
|
# @yield [Coverage] the path to the file, and the execution counts.
|
44
76
|
def each(&block)
|
45
|
-
@output.each(&block)
|
77
|
+
@output.each(&block)
|
46
78
|
end
|
47
79
|
|
48
80
|
def relative_path(path)
|
49
|
-
|
50
|
-
@output.relative_path(path)
|
51
|
-
else
|
52
|
-
path
|
53
|
-
end
|
81
|
+
@output.relative_path(path)
|
54
82
|
end
|
55
83
|
|
56
84
|
def expand_path(path)
|
57
|
-
|
58
|
-
@output.expand_path(path)
|
59
|
-
else
|
60
|
-
path
|
61
|
-
end
|
85
|
+
@output.expand_path(path)
|
62
86
|
end
|
63
87
|
|
64
88
|
def to_h
|
65
|
-
collect{|coverage| [coverage.path, coverage]}.to_h
|
89
|
+
@output.to_enum(:each).collect{|coverage| [coverage.path, coverage]}.to_h
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class Filter < Wrapper
|
94
|
+
def mark(path, lineno, value)
|
95
|
+
@output.mark(path, lineno, value) if accept?(path)
|
96
|
+
end
|
97
|
+
|
98
|
+
# @yield [Coverage] the path to the file, and the execution counts.
|
99
|
+
def each(&block)
|
100
|
+
@output.each do |coverage|
|
101
|
+
yield coverage if accept?(coverage.path)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def accept?(path)
|
106
|
+
match?(path) and super
|
107
|
+
end
|
108
|
+
|
109
|
+
def match?(path)
|
110
|
+
true
|
66
111
|
end
|
67
112
|
end
|
68
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: msgpack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: async-rest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +158,7 @@ files:
|
|
144
158
|
- lib/covered/eval.rb
|
145
159
|
- lib/covered/files.rb
|
146
160
|
- lib/covered/minitest.rb
|
161
|
+
- lib/covered/persist.rb
|
147
162
|
- lib/covered/policy.rb
|
148
163
|
- lib/covered/policy/default.rb
|
149
164
|
- lib/covered/rspec.rb
|