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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 031ca916bcee96033586ba0e1c6f7a93129b8b758a1c297c9555d9de91bb14af
4
- data.tar.gz: 0dd69d9959a49fc94518926d498cb3350ec1d952de2887853fa09b0497011c2d
3
+ metadata.gz: 7f17a50188404018a1e6a33f0ab5c71ddddabe4ac2686d3089bd6fb4b4e690d5
4
+ data.tar.gz: c4a47f69c6fd77ab84a12b698fb1a725c4719a4451d3afdb95d40fbd99b35e39
5
5
  SHA512:
6
- metadata.gz: 548640eb62924ec9d465fa6521c57fdf9cf1b2e63075a171bb24128d3dfbf8793e5f0165dd233ab898e7a9f7c63af431591eac5645fb1ed574d5a7dc26b7584a
7
- data.tar.gz: 1017152226c61dd4e2d588f59c62cd2a9a6b4f9a126dece207b27e0fc11281b164cd7456b7a12a6146464092d2d58966d417d40f1910536c5a817b6cdf4bd25d
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
@@ -20,11 +20,11 @@ module OneshotCoverage
20
20
  end
21
21
 
22
22
  class Reporter
23
- def initialize(target_path:, logger:, max_emit_per_request:)
23
+ def initialize(target_path:, logger:, max_emit_at_once:)
24
24
  @target_path = target_path
25
25
  @logger = logger
26
26
  @buffer = []
27
- @max_emit_per_request = max_emit_per_request
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(emit_per_request).each { |row| @logger.post(row) }
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 emit_per_request
72
- @max_emit_per_request || @buffer.size
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, max_emit_per_request: nil)
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
- max_emit_per_request: max_emit_per_request
106
+ max_emit_at_once: max_emit_at_once
102
107
  )
103
108
  end
104
109
  end
@@ -3,6 +3,7 @@ module OneshotCoverage
3
3
  class NullLogger
4
4
  def post(_row)
5
5
  # Do nothing
6
+ true
6
7
  end
7
8
  end
8
9
  end
@@ -5,6 +5,7 @@ module OneshotCoverage
5
5
  $stdout.puts(
6
6
  "[OneshotCoverage] logged path: #{path}, md5_hash: #{md5_hash}, lineno: #{lineno}"
7
7
  )
8
+ true
8
9
  end
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module OneshotCoverage
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  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.0
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-20 00:00:00.000000000 Z
11
+ date: 2019-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler