cover_rage 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cover_rage/recorder.rb +10 -5
- data/lib/cover_rage/stores/pstore.rb +23 -8
- data/lib/cover_rage/stores/redis.rb +15 -12
- data/lib/cover_rage/stores/sqlite.rb +23 -34
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e35c3c64110ebafa0432d4ac37f2d05b19a552df8505263f751f4fb85a841525
|
4
|
+
data.tar.gz: 9cd16923a839fd2ddcd6f5b585d28bfc19ab40a466d810ac8a93378bf5c13b02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1b158a2dc50611a60482aeae2f448c9f4f8ae59f3d1ebb6ecd29bc03fea38a82a934b4b84906a4f331a7b293ccfcb4780ab7d956fe24015c42c54a8d4a52cdc
|
7
|
+
data.tar.gz: b06bdca3118bf5d80f7225e4792d258a18ef17a27f9255e0993a0e9523aab81e1aa88051b6c6670241ea688bfd10df10118ce9934e84e1c4379d4fcae02b7282
|
data/lib/cover_rage/recorder.rb
CHANGED
@@ -26,7 +26,7 @@ module CoverRage
|
|
26
26
|
interval = Config.interval
|
27
27
|
jitter = 0.15
|
28
28
|
loop do
|
29
|
-
sleep(interval + rand * interval * jitter)
|
29
|
+
sleep(interval + (rand * interval * jitter))
|
30
30
|
save(Coverage.result(stop: false, clear: true))
|
31
31
|
end
|
32
32
|
end
|
@@ -44,12 +44,17 @@ module CoverRage
|
|
44
44
|
|
45
45
|
records << Record.new(
|
46
46
|
path: relative_path,
|
47
|
-
revision
|
48
|
-
source
|
49
|
-
execution_count:
|
47
|
+
revision:,
|
48
|
+
source:,
|
49
|
+
execution_count:
|
50
50
|
)
|
51
51
|
end
|
52
|
-
|
52
|
+
return unless records.any?
|
53
|
+
|
54
|
+
@store.transaction do
|
55
|
+
records_to_save = Record.merge(@store.list, records)
|
56
|
+
@store.update(records_to_save)
|
57
|
+
end
|
53
58
|
end
|
54
59
|
|
55
60
|
private
|
@@ -10,27 +10,42 @@ module CoverRage
|
|
10
10
|
@store = PStore.new(path, true)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def transaction
|
14
14
|
@store.transaction do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
@transaction = true
|
16
|
+
yield
|
17
|
+
ensure
|
18
|
+
@transaction = false
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
-
@
|
22
|
+
def update(records)
|
23
|
+
if @transaction
|
24
|
+
records.each { @store[_1.path] = _1 }
|
25
|
+
else
|
26
|
+
@store.transaction do
|
27
|
+
records.each { @store[_1.path] = _1 }
|
28
|
+
end
|
29
|
+
end
|
23
30
|
end
|
24
31
|
|
25
32
|
def list
|
26
|
-
@
|
33
|
+
if @transaction
|
27
34
|
@store.keys.map { @store[_1] }
|
35
|
+
else
|
36
|
+
@store.transaction do
|
37
|
+
@store.keys.map { @store[_1] }
|
38
|
+
end
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
42
|
def clear
|
32
|
-
@
|
43
|
+
if @transaction
|
33
44
|
@store.keys.each { @store.delete(_1) }
|
45
|
+
else
|
46
|
+
@store.transaction do
|
47
|
+
@store.keys.each { @store.delete(_1) }
|
48
|
+
end
|
34
49
|
end
|
35
50
|
end
|
36
51
|
end
|
@@ -12,30 +12,33 @@ module CoverRage
|
|
12
12
|
def initialize(url)
|
13
13
|
@redis =
|
14
14
|
if url.start_with?('rediss')
|
15
|
-
::Redis.new(url
|
15
|
+
::Redis.new(url:, ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
|
16
16
|
else
|
17
|
-
::Redis.new(url:
|
17
|
+
::Redis.new(url:)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def transaction(&)
|
22
22
|
loop do
|
23
23
|
break if @redis.watch(KEY) do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
@redis.multi do |multi|
|
25
|
+
Thread.current[:redis_multi] = multi
|
26
|
+
yield
|
27
|
+
ensure
|
28
|
+
Thread.current[:redis_multi] = nil
|
28
29
|
end
|
29
|
-
@redis.multi { _1.hset(KEY, *arguments) }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
34
|
+
def update(records)
|
35
|
+
arguments = []
|
36
|
+
records.each do |record|
|
37
|
+
arguments.push(record.path, JSON.dump(record.to_h))
|
38
|
+
end
|
37
39
|
|
38
|
-
|
40
|
+
client = Thread.current[:redis_multi] || @redis
|
41
|
+
client.hset(KEY, *arguments)
|
39
42
|
end
|
40
43
|
|
41
44
|
def list
|
@@ -8,6 +8,8 @@ module CoverRage
|
|
8
8
|
module Stores
|
9
9
|
class Sqlite
|
10
10
|
def initialize(path)
|
11
|
+
@mutex = Mutex.new
|
12
|
+
@path = path
|
11
13
|
@db = SQLite3::Database.new(path)
|
12
14
|
@db.execute <<-SQL
|
13
15
|
create table if not exists records (
|
@@ -29,40 +31,27 @@ module CoverRage
|
|
29
31
|
Process.singleton_class.prepend(process_ext)
|
30
32
|
end
|
31
33
|
|
32
|
-
def
|
33
|
-
@
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
(['(?,?,?,?)'] * records_to_save.length).join(',')
|
38
|
-
}",
|
39
|
-
records_to_save.each_with_object([]) do |record, memo|
|
40
|
-
memo.push(
|
41
|
-
record.path,
|
42
|
-
record.revision,
|
43
|
-
record.source,
|
44
|
-
JSON.dump(record.execution_count)
|
45
|
-
)
|
46
|
-
end
|
47
|
-
)
|
34
|
+
def transaction(&)
|
35
|
+
@mutex.synchronize do
|
36
|
+
@db.transaction(:exclusive, &)
|
37
|
+
rescue SQLite3::BusyException
|
38
|
+
retry
|
48
39
|
end
|
49
|
-
rescue SQLite3::BusyException
|
50
|
-
retry
|
51
40
|
end
|
52
41
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
42
|
+
def update(records)
|
43
|
+
@db.execute(
|
44
|
+
"insert or replace into records (path, revision, source, execution_count) values #{
|
45
|
+
(['(?,?,?,?)'] * records.length).join(',')
|
46
|
+
}",
|
47
|
+
records.each_with_object([]) do |record, memo|
|
48
|
+
memo.push(
|
49
|
+
record.path,
|
50
|
+
record.revision,
|
51
|
+
record.source,
|
52
|
+
JSON.dump(record.execution_count)
|
53
|
+
)
|
54
|
+
end
|
66
55
|
)
|
67
56
|
end
|
68
57
|
|
@@ -71,9 +60,9 @@ module CoverRage
|
|
71
60
|
.execute('select path, revision, source, execution_count from records')
|
72
61
|
.map do |(path, revision, source, execution_count)|
|
73
62
|
Record.new(
|
74
|
-
path
|
75
|
-
revision
|
76
|
-
source
|
63
|
+
path:,
|
64
|
+
revision:,
|
65
|
+
source:,
|
77
66
|
execution_count: JSON.parse(execution_count)
|
78
67
|
)
|
79
68
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cover_rage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weihang Jian
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-12-
|
10
|
+
date: 2024-12-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: minitest
|
@@ -95,7 +95,8 @@ files:
|
|
95
95
|
homepage: https://github.com/tonytonyjan/cover_rage
|
96
96
|
licenses:
|
97
97
|
- MIT
|
98
|
-
metadata:
|
98
|
+
metadata:
|
99
|
+
rubygems_mfa_required: 'true'
|
99
100
|
rdoc_options: []
|
100
101
|
require_paths:
|
101
102
|
- lib
|