cover_rage 1.1.1 → 1.2.0
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 +4 -4
- data/lib/cover_rage/record.rb +8 -1
- data/lib/cover_rage/recorder.rb +5 -1
- data/lib/cover_rage/reporters/html_reporter/index.html.erb +15 -4
- data/lib/cover_rage/stores/sqlite.rb +12 -9
- metadata +9 -51
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5621019f54428ba46ed131c128c14da48bb2e9fd2bc10e283a3c0c8f8642b2c0
|
|
4
|
+
data.tar.gz: a1a8912ce53c591c178923f790c6eba60651fb22834489513b89368a785dfea2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 10fafa62c5ddc3c37b1be895d7875c116c44343ea2bed5b18ff3571003958c6867ef40c2945ec70f4747a84760dc786e9ef5fc6c14865e770f7283a05a6004a0
|
|
7
|
+
data.tar.gz: 5d60032466d783830936617366c326df471fde464428fbabf00b0e8e390b1f9b1c79d9c384ea15f5d80448a1f6edd4d3ec5e369b273dbc659e19f6ba053da3d9
|
data/lib/cover_rage/record.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module CoverRage
|
|
4
|
-
Record = Data.define(:path, :revision, :source, :execution_count) do
|
|
4
|
+
Record = Data.define(:path, :revision, :source, :execution_count, :last_executed_at) do
|
|
5
5
|
def self.merge(existing, current)
|
|
6
6
|
records_to_save = []
|
|
7
7
|
current.each do |record|
|
|
@@ -20,6 +20,13 @@ module CoverRage
|
|
|
20
20
|
with(
|
|
21
21
|
execution_count: execution_count.map.with_index do |item, index|
|
|
22
22
|
item.nil? ? nil : item + other.execution_count[index]
|
|
23
|
+
end,
|
|
24
|
+
last_executed_at: last_executed_at.map.with_index do |item, index|
|
|
25
|
+
if item.nil? && other.last_executed_at[index].nil? then nil
|
|
26
|
+
elsif item.nil? then other.last_executed_at[index]
|
|
27
|
+
elsif other.last_executed_at[index].nil? then item
|
|
28
|
+
else [item.to_i, other.last_executed_at[index].to_i].max
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
)
|
|
25
32
|
end
|
data/lib/cover_rage/recorder.rb
CHANGED
|
@@ -42,11 +42,15 @@ module CoverRage
|
|
|
42
42
|
relative_path = filepath.delete_prefix(@path_prefix)
|
|
43
43
|
revision, source = read_file_with_revision(filepath)
|
|
44
44
|
|
|
45
|
+
now = Time.now.to_i
|
|
46
|
+
last_executed_at = execution_count.map { |c| c&.positive? ? now : nil }
|
|
47
|
+
|
|
45
48
|
records << Record.new(
|
|
46
49
|
path: relative_path,
|
|
47
50
|
revision:,
|
|
48
51
|
source:,
|
|
49
|
-
execution_count
|
|
52
|
+
execution_count:,
|
|
53
|
+
last_executed_at:
|
|
50
54
|
)
|
|
51
55
|
end
|
|
52
56
|
return unless records.any?
|
|
@@ -27,11 +27,18 @@
|
|
|
27
27
|
.number {
|
|
28
28
|
display: inline-block;
|
|
29
29
|
text-align: right;
|
|
30
|
-
margin-right: 0.5em;
|
|
31
30
|
background-color: lightgray;
|
|
32
31
|
padding: 0 0.5em 0 1.5em;
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
.timestamp {
|
|
35
|
+
display: inline-block;
|
|
36
|
+
text-align: right;
|
|
37
|
+
margin-right: 0.5em;
|
|
38
|
+
background-color: lightgray;
|
|
39
|
+
padding: 0 0.5em 0 0.5em;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
.nav {
|
|
36
43
|
display: flex;
|
|
37
44
|
list-style: none;
|
|
@@ -123,9 +130,13 @@
|
|
|
123
130
|
if (typeof value === "number")
|
|
124
131
|
color = value > 0 ? "green" : "red";
|
|
125
132
|
const number = typeof value === "number" ? value : "-";
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
const posix_time = record.last_executed_at[index];
|
|
134
|
+
const iso8601_time = typeof posix_time === "number" ? new Date(posix_time * 1000).toISOString().slice(0, 10) : "-";
|
|
135
|
+
return `<span class="line ${color}"><span class="number">${
|
|
136
|
+
number.toString().padStart(digit_width, " ")
|
|
137
|
+
}</span><time class="timestamp">${
|
|
138
|
+
iso8601_time.padStart(10, " ")
|
|
139
|
+
}</time>${line}</span>`;
|
|
129
140
|
})
|
|
130
141
|
.join("\n");
|
|
131
142
|
}
|
|
@@ -11,12 +11,14 @@ module CoverRage
|
|
|
11
11
|
@mutex = Mutex.new
|
|
12
12
|
@path = path
|
|
13
13
|
@db = SQLite3::Database.new(path)
|
|
14
|
+
@db.busy_handler { true }
|
|
14
15
|
@db.execute <<-SQL
|
|
15
16
|
create table if not exists records (
|
|
16
17
|
path text primary key not null,
|
|
17
18
|
revision blob not null,
|
|
18
19
|
source text not null,
|
|
19
|
-
execution_count text not null
|
|
20
|
+
execution_count text not null,
|
|
21
|
+
last_executed_at text not null
|
|
20
22
|
)
|
|
21
23
|
SQL
|
|
22
24
|
process_ext = Module.new
|
|
@@ -25,6 +27,7 @@ module CoverRage
|
|
|
25
27
|
store.instance_variable_get(:@db).close
|
|
26
28
|
pid = super()
|
|
27
29
|
store.instance_variable_set(:@db, SQLite3::Database.new(path))
|
|
30
|
+
store.instance_variable_get(:@db).busy_handler { true }
|
|
28
31
|
pid
|
|
29
32
|
end
|
|
30
33
|
end
|
|
@@ -34,22 +37,21 @@ module CoverRage
|
|
|
34
37
|
def transaction(&)
|
|
35
38
|
@mutex.synchronize do
|
|
36
39
|
@db.transaction(:exclusive, &)
|
|
37
|
-
rescue SQLite3::BusyException
|
|
38
|
-
retry
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def update(records)
|
|
43
44
|
@db.execute(
|
|
44
|
-
"insert or replace into records (path, revision, source, execution_count) values #{
|
|
45
|
-
(['(
|
|
45
|
+
"insert or replace into records (path, revision, source, execution_count, last_executed_at) values #{
|
|
46
|
+
(['(?,?,?,?,?)'] * records.length).join(',')
|
|
46
47
|
}",
|
|
47
48
|
records.each_with_object([]) do |record, memo|
|
|
48
49
|
memo.push(
|
|
49
50
|
record.path,
|
|
50
51
|
record.revision,
|
|
51
52
|
record.source,
|
|
52
|
-
JSON.dump(record.execution_count)
|
|
53
|
+
JSON.dump(record.execution_count),
|
|
54
|
+
JSON.dump(record.last_executed_at)
|
|
53
55
|
)
|
|
54
56
|
end
|
|
55
57
|
)
|
|
@@ -57,13 +59,14 @@ module CoverRage
|
|
|
57
59
|
|
|
58
60
|
def list
|
|
59
61
|
@db
|
|
60
|
-
.execute('select path, revision, source, execution_count from records')
|
|
61
|
-
.map do |(path, revision, source, execution_count)|
|
|
62
|
+
.execute('select path, revision, source, execution_count, last_executed_at from records')
|
|
63
|
+
.map do |(path, revision, source, execution_count, last_executed_at)|
|
|
62
64
|
Record.new(
|
|
63
65
|
path:,
|
|
64
66
|
revision:,
|
|
65
67
|
source:,
|
|
66
|
-
execution_count: JSON.parse(execution_count)
|
|
68
|
+
execution_count: JSON.parse(execution_count),
|
|
69
|
+
last_executed_at: JSON.parse(last_executed_at)
|
|
67
70
|
)
|
|
68
71
|
end
|
|
69
72
|
end
|
metadata
CHANGED
|
@@ -1,70 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cover_rage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Weihang Jian
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
13
|
+
name: pstore
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '
|
|
19
|
-
type: :
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
|
-
- - "
|
|
23
|
+
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: rake
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '13.0'
|
|
33
|
-
type: :development
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '13.0'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: redis
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '5.3'
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '5.3'
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: sqlite3
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '2.5'
|
|
61
|
-
type: :development
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - "~>"
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: '2.5'
|
|
25
|
+
version: '0'
|
|
68
26
|
description: |
|
|
69
27
|
cover_rage is a Ruby code coverage tool designed to be simple and easy to use. It can be used not only for test coverage but also in production services to identify unused code.
|
|
70
28
|
|
|
@@ -111,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
111
69
|
- !ruby/object:Gem::Version
|
|
112
70
|
version: '0'
|
|
113
71
|
requirements: []
|
|
114
|
-
rubygems_version:
|
|
72
|
+
rubygems_version: 4.0.4
|
|
115
73
|
specification_version: 4
|
|
116
74
|
summary: cover_rage is a Ruby code coverage tool designed to be simple and easy to
|
|
117
75
|
use. It can be used not only for test coverage but also in production services to
|