akainaa 0.1.5 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6602589d81aa7812d340812b17c6cc253356605aaf40fc3746aa1ab409b0d94
4
- data.tar.gz: f4c7d56da714844abb1dc8f8a9977b3cb14065d2eec7c852e9b1aa902f212cff
3
+ metadata.gz: 5c243fb0962753dd244afa73ff9f26176ee9dc642c5c5cf850fc16c113091875
4
+ data.tar.gz: e4129d45be238490a2cb9d0b6762049a159fbc199b2a4e1c4e36b898942b68ab
5
5
  SHA512:
6
- metadata.gz: 21b88780fb3299dc630d3aa83dc0a7fa8cc94d486e908c54c3681c87d3ac619eef2cdf71c646f6aa71d01016b64573de338cbc09f8a8b3367f836902a74571b8
7
- data.tar.gz: 7239bd4af6b74ee056ac78959b8220a2bebddadcc4b0bc6a21f58ad7bb5471c44f51810032b56912e3c3c4743baadaf530235b11f10930915fcdeed7bd27dc83
6
+ metadata.gz: 011f7c34de5d2d107a93daac019afda4233136d250f6665117e50d926fd3bc390de80d5657a49c12832937207020793b6fc34eeb06345dc252a9e6ef88774711
7
+ data.tar.gz: 90f99fbf909d9b5ae4c1ad9c719b2d6676c0a67b7ae6c43ad6317ec6de246f2c5b798c935de7b2d782c5e5181273ac7c6cea0c3046145d5e1924a2fc393687bc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.7]
4
+
5
+ - Bug fix: Require "json" on start if online_emit enabled
6
+
7
+ ## [0.1.6] - 2024-09-11
8
+
9
+ - Feature: Add `clear` flag on first emit
10
+ - Feature: Add `trap_at_exit` option to `Akainaa.start` method
11
+ - Feature: Do not emit regularly if interval is 0 or nil
12
+
3
13
  ## [0.1.5] - 2024-09-10
4
14
 
5
15
  - Bug fix: nested method call won't handled
data/README.md CHANGED
@@ -61,6 +61,7 @@ Akainaa.start(
61
61
  mode: :file,
62
62
  interval: 1, # seconds
63
63
  output_path: '/tmp/akainaa.json',
64
+ trap_at_exit: true,
64
65
  },
65
66
  )
66
67
  ```
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Akainaa
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
data/lib/akainaa.rb CHANGED
@@ -27,13 +27,21 @@ module Akainaa
27
27
  @ignore_files = Set.new(ignore_files)
28
28
  @hide_not_executed_files = hide_not_executed_files
29
29
  @monitor = Monitor.new
30
+ @first_emitted = false
30
31
 
31
32
  Coverage.start(lines: true)
32
33
 
33
34
  if online_emit.is_a?(Hash)
35
+ require 'json'
34
36
  option = default_online_emit.merge(online_emit)
35
37
  FileUtils.mkdir_p(File.dirname(option[:path]))
36
38
  start_multipart_emit(option)
39
+
40
+ if option[:trap_at_exit]
41
+ at_exit do
42
+ write_result(peek_result, option[:path])
43
+ end
44
+ end
37
45
  end
38
46
  end
39
47
 
@@ -52,15 +60,26 @@ module Akainaa
52
60
  end
53
61
  end
54
62
 
63
+ private def write_result(result, path)
64
+ unless @first_emitted
65
+ result['clear'] = true
66
+ end
67
+ File.write(path, result.to_json)
68
+ @first_emitted = true
69
+ end
70
+
55
71
  private def default_online_emit
56
72
  {
57
73
  mode: :file,
58
74
  interval: 1,
59
75
  path: 'tmp/coverage.json',
76
+ trap_at_exit: true,
60
77
  }
61
78
  end
62
79
 
63
80
  private def start_multipart_emit(option)
81
+ return if option[:interval].nil? || option[:interval] <= 0
82
+
64
83
  Thread.new do
65
84
  @monitor.synchronize do
66
85
  @previous_result = {}
@@ -92,7 +111,8 @@ module Akainaa
92
111
  @monitor.synchronize do
93
112
  @previous_result = current_result
94
113
  end
95
- File.write(option[:path], diff.to_json)
114
+
115
+ write_result(diff, option[:path])
96
116
  end
97
117
  end
98
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akainaa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-10 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Minimum rack middleware for coverage
14
14
  email:
@@ -32,7 +32,7 @@ metadata:
32
32
  homepage_uri: https://github.com/riseshia/akainaa
33
33
  source_code_uri: https://github.com/riseshia/akainaa
34
34
  changelog_uri: https://github.com/riseshia/akainaa/blob/main/CHANGELOG.md
35
- post_install_message:
35
+ post_install_message:
36
36
  rdoc_options: []
37
37
  require_paths:
38
38
  - lib
@@ -47,8 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  requirements: []
50
- rubygems_version: 3.5.11
51
- signing_key:
50
+ rubygems_version: 3.5.3
51
+ signing_key:
52
52
  specification_version: 4
53
53
  summary: Minimum rack middleware for coverage
54
54
  test_files: []