oneshot_coverage 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oneshot_coverage/version.rb +1 -1
- data/lib/oneshot_coverage.rb +12 -3
- 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: 031ca916bcee96033586ba0e1c6f7a93129b8b758a1c297c9555d9de91bb14af
|
4
|
+
data.tar.gz: 0dd69d9959a49fc94518926d498cb3350ec1d952de2887853fa09b0497011c2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 548640eb62924ec9d465fa6521c57fdf9cf1b2e63075a171bb24128d3dfbf8793e5f0165dd233ab898e7a9f7c63af431591eac5645fb1ed574d5a7dc26b7584a
|
7
|
+
data.tar.gz: 1017152226c61dd4e2d588f59c62cd2a9a6b4f9a126dece207b27e0fc11281b164cd7456b7a12a6146464092d2d58966d417d40f1910536c5a817b6cdf4bd25d
|
data/lib/oneshot_coverage.rb
CHANGED
@@ -20,9 +20,11 @@ module OneshotCoverage
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class Reporter
|
23
|
-
def initialize(target_path:, logger:)
|
23
|
+
def initialize(target_path:, logger:, max_emit_per_request:)
|
24
24
|
@target_path = target_path
|
25
25
|
@logger = logger
|
26
|
+
@buffer = []
|
27
|
+
@max_emit_per_request = max_emit_per_request
|
26
28
|
if defined?(Bundler)
|
27
29
|
@bundler_path = Bundler.bundle_path.to_s
|
28
30
|
end
|
@@ -32,7 +34,9 @@ module OneshotCoverage
|
|
32
34
|
Coverage.result(clear: true, stop: false).
|
33
35
|
select { |k, v| is_target?(k, v) }.
|
34
36
|
flat_map { |k, v| transform(k, v) }.
|
35
|
-
each { |row| @
|
37
|
+
each { |row| @buffer << row }
|
38
|
+
|
39
|
+
@buffer.shift(emit_per_request).each { |row| @logger.post(row) }
|
36
40
|
end
|
37
41
|
|
38
42
|
def is_target?(filepath, value)
|
@@ -63,6 +67,10 @@ module OneshotCoverage
|
|
63
67
|
def md5_hash_cache
|
64
68
|
@md5_hash_cache ||= {}
|
65
69
|
end
|
70
|
+
|
71
|
+
def emit_per_request
|
72
|
+
@max_emit_per_request || @buffer.size
|
73
|
+
end
|
66
74
|
end
|
67
75
|
|
68
76
|
module_function
|
@@ -80,7 +88,7 @@ module OneshotCoverage
|
|
80
88
|
@reporter&.emit
|
81
89
|
end
|
82
90
|
|
83
|
-
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new)
|
91
|
+
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new, max_emit_per_request: nil)
|
84
92
|
target_path_by_pathname =
|
85
93
|
if target_path.is_a? Pathname
|
86
94
|
target_path
|
@@ -90,6 +98,7 @@ module OneshotCoverage
|
|
90
98
|
@reporter = OneshotCoverage::Reporter.new(
|
91
99
|
target_path: target_path_by_pathname.cleanpath.to_s + "/",
|
92
100
|
logger: logger,
|
101
|
+
max_emit_per_request: max_emit_per_request
|
93
102
|
)
|
94
103
|
end
|
95
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneshot_coverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|