oneshot_coverage 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/oneshot_coverage.rb +12 -7
- data/lib/oneshot_coverage/logger/null_logger.rb +1 -0
- data/lib/oneshot_coverage/logger/stdout_logger.rb +1 -0
- data/lib/oneshot_coverage/version.rb +1 -1
- 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: 7f17a50188404018a1e6a33f0ab5c71ddddabe4ac2686d3089bd6fb4b4e690d5
|
4
|
+
data.tar.gz: c4a47f69c6fd77ab84a12b698fb1a725c4719a4451d3afdb95d40fbd99b35e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c09df9d74e6e6975e41933653b6c7904097e54eccaf50d24a18b5dd3f047d18eee8c8bd503c59bfc1bc1bccebd8381e0375b4359882c79b9ef95fd54bca84c9
|
7
|
+
data.tar.gz: bcb475a7d9ef58378738c0bd93126ba3b5ba1edb183272bb8f624f492b16b03616d84faace863c05b212f24c1d1bf2b9631135496283675d47a25b786e777448
|
data/README.md
CHANGED
@@ -35,6 +35,7 @@ Or install it yourself as:
|
|
35
35
|
OneshotCoverage.configure(
|
36
36
|
target_path: '/base/project/path',
|
37
37
|
logger: OneshotCoverage::Logger::NullLogger.new,
|
38
|
+
max_emit_at_once: nil, # Flush all when it set to `nil`, which is default
|
38
39
|
)
|
39
40
|
OneshotCoverage.start
|
40
41
|
```
|
@@ -59,6 +60,9 @@ class SampleFluentLogger
|
|
59
60
|
end
|
60
61
|
```
|
61
62
|
|
63
|
+
Please note that it will retry to send data if `#post` returns falsy value.
|
64
|
+
Hence, make sure to return `true` if you don't want to retry.
|
65
|
+
|
62
66
|
### Emit logs
|
63
67
|
|
64
68
|
#### With rack application
|
data/lib/oneshot_coverage.rb
CHANGED
@@ -20,11 +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_at_once:)
|
24
24
|
@target_path = target_path
|
25
25
|
@logger = logger
|
26
26
|
@buffer = []
|
27
|
-
@
|
27
|
+
@max_emit_at_once = max_emit_at_once
|
28
28
|
if defined?(Bundler)
|
29
29
|
@bundler_path = Bundler.bundle_path.to_s
|
30
30
|
end
|
@@ -36,7 +36,12 @@ module OneshotCoverage
|
|
36
36
|
flat_map { |k, v| transform(k, v) }.
|
37
37
|
each { |row| @buffer << row }
|
38
38
|
|
39
|
-
@buffer.shift(
|
39
|
+
@buffer.shift(emit_at_once).each do |row|
|
40
|
+
# Retry when fail to post
|
41
|
+
unless @logger.post(row)
|
42
|
+
@buffer << row
|
43
|
+
end
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
47
|
def is_target?(filepath, value)
|
@@ -68,8 +73,8 @@ module OneshotCoverage
|
|
68
73
|
@md5_hash_cache ||= {}
|
69
74
|
end
|
70
75
|
|
71
|
-
def
|
72
|
-
@
|
76
|
+
def emit_at_once
|
77
|
+
@max_emit_at_once || @buffer.size
|
73
78
|
end
|
74
79
|
end
|
75
80
|
|
@@ -88,7 +93,7 @@ module OneshotCoverage
|
|
88
93
|
@reporter&.emit
|
89
94
|
end
|
90
95
|
|
91
|
-
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new,
|
96
|
+
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new, max_emit_at_once: nil)
|
92
97
|
target_path_by_pathname =
|
93
98
|
if target_path.is_a? Pathname
|
94
99
|
target_path
|
@@ -98,7 +103,7 @@ module OneshotCoverage
|
|
98
103
|
@reporter = OneshotCoverage::Reporter.new(
|
99
104
|
target_path: target_path_by_pathname.cleanpath.to_s + "/",
|
100
105
|
logger: logger,
|
101
|
-
|
106
|
+
max_emit_at_once: max_emit_at_once
|
102
107
|
)
|
103
108
|
end
|
104
109
|
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.2.
|
4
|
+
version: 0.2.1
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|