cover_rage 0.0.6 → 1.0.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/config.rb +11 -6
- data/lib/cover_rage/launcher.rb +1 -1
- data/lib/cover_rage/recorder.rb +10 -10
- data/lib/cover_rage/stores/pstore.rb +38 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5475081d89068cc543f39035786796e346ca90364f30c525680f4458118c211c
|
4
|
+
data.tar.gz: 954ed2e2a6d4173e99b533c8914fd4c517730b53262bdbce0193c937644ad524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e73234c452933ed861dec4cde8735e455ed5ea36ccbc9fc682bd7f695f43573ebfc5f5fb723b57c490af2fdd56743480e5812efd67a521f3f8672169d2d7af7d
|
7
|
+
data.tar.gz: 36635a50188153c1f5d1df5b24eb024f12bcfc3b28496ec0deb2eaa918cd13cb571822945109b674f552b2f7fcad23519ef3347fc99d6e8f1ef91f85fdfdd179
|
data/lib/cover_rage/config.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require 'uri'
|
4
4
|
module CoverRage
|
5
5
|
module Config
|
6
|
-
def self.
|
7
|
-
@
|
6
|
+
def self.path_prefix
|
7
|
+
@path_prefix ||= ENV.fetch('COVER_RAGE_PATH_PREFIX', defined?(Rails) && Rails.root ? Rails.root.to_s : Dir.pwd)
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.store
|
11
11
|
@store ||= begin
|
12
|
-
uri = URI.parse(ENV.fetch('COVER_RAGE_STORE_URL'))
|
12
|
+
uri = URI.parse(ENV.fetch('COVER_RAGE_STORE_URL', "pstore:#{File.join(Dir.pwd, 'cover_rage.pstore')}"))
|
13
13
|
case uri.scheme
|
14
14
|
when 'redis', 'rediss'
|
15
15
|
require 'cover_rage/stores/redis'
|
@@ -17,14 +17,19 @@ module CoverRage
|
|
17
17
|
when 'sqlite'
|
18
18
|
require 'cover_rage/stores/sqlite'
|
19
19
|
CoverRage::Stores::Sqlite.new(uri.path)
|
20
|
+
when 'pstore'
|
21
|
+
require 'cover_rage/stores/pstore'
|
22
|
+
CoverRage::Stores::Pstore.new(uri.path)
|
23
|
+
else
|
24
|
+
raise "Unsupported store: #{uri.scheme}"
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
24
|
-
def self.
|
25
|
-
@
|
29
|
+
def self.interval
|
30
|
+
@interval ||= begin
|
26
31
|
args =
|
27
|
-
ENV.fetch('
|
32
|
+
ENV.fetch('COVER_RAGE_INTERVAL', '60:90').split(':').map!(&:to_i).first(2)
|
28
33
|
args.push(args.first.succ) if args.length < 2
|
29
34
|
Range.new(*args, true)
|
30
35
|
end
|
data/lib/cover_rage/launcher.rb
CHANGED
data/lib/cover_rage/recorder.rb
CHANGED
@@ -6,13 +6,12 @@ require 'digest'
|
|
6
6
|
|
7
7
|
module CoverRage
|
8
8
|
class Recorder
|
9
|
-
|
10
|
-
COVERAGE_STOP_STATES = %i[idle suspended].freeze
|
9
|
+
INTERVAL = Config.interval
|
11
10
|
attr_reader :store
|
12
11
|
|
13
|
-
def initialize(
|
12
|
+
def initialize(path_prefix:, store:)
|
14
13
|
@store = store
|
15
|
-
@
|
14
|
+
@path_prefix = path_prefix.end_with?('/') ? path_prefix : "#{path_prefix}/"
|
16
15
|
@digest = Digest::MD5.new
|
17
16
|
@file_cache = {}
|
18
17
|
end
|
@@ -20,14 +19,15 @@ module CoverRage
|
|
20
19
|
def start
|
21
20
|
return if @thread&.alive?
|
22
21
|
|
23
|
-
Coverage.
|
22
|
+
unless Coverage.running?
|
23
|
+
Coverage.start
|
24
|
+
at_exit { save(Coverage.result) }
|
25
|
+
end
|
24
26
|
@thread = Thread.new do
|
25
27
|
loop do
|
26
|
-
sleep(rand(
|
28
|
+
sleep(rand(INTERVAL))
|
27
29
|
save(Coverage.result(stop: false, clear: true))
|
28
30
|
end
|
29
|
-
ensure
|
30
|
-
save(Coverage.result)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -37,10 +37,10 @@ module CoverRage
|
|
37
37
|
records = []
|
38
38
|
coverage_result.map do |filepath, execution_count|
|
39
39
|
filepath = File.expand_path(filepath) unless filepath.start_with?('/')
|
40
|
-
next unless filepath.start_with?(@
|
40
|
+
next unless filepath.start_with?(@path_prefix)
|
41
41
|
next if execution_count.all? { _1.nil? || _1.zero? }
|
42
42
|
|
43
|
-
relative_path = filepath.delete_prefix(@
|
43
|
+
relative_path = filepath.delete_prefix(@path_prefix)
|
44
44
|
revision, source = read_file_with_revision(filepath)
|
45
45
|
|
46
46
|
records << Record.new(
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cover_rage/record'
|
4
|
+
require 'pstore'
|
5
|
+
|
6
|
+
module CoverRage
|
7
|
+
module Stores
|
8
|
+
class Pstore
|
9
|
+
def initialize(path)
|
10
|
+
@store = PStore.new(path, true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def import(records)
|
14
|
+
@store.transaction do
|
15
|
+
persisted_records = @store.keys.map { @store[_1] }
|
16
|
+
records_to_save = Record.merge(persisted_records, records)
|
17
|
+
records_to_save.each { @store[_1.path] = _1 }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find(path)
|
22
|
+
@store.transaction { @store[path] }
|
23
|
+
end
|
24
|
+
|
25
|
+
def list
|
26
|
+
@store.transaction do
|
27
|
+
@store.keys.map { @store[_1] }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear
|
32
|
+
@store.transaction do
|
33
|
+
@store.keys.each { @store.delete(_1) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cover_rage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weihang Jian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -41,9 +41,10 @@ dependencies:
|
|
41
41
|
description: |
|
42
42
|
A Ruby production code coverage tool designed to assist you in identifying unused code, offering the following features:
|
43
43
|
|
44
|
-
1.
|
45
|
-
2.
|
46
|
-
3.
|
44
|
+
1. zero dependencies
|
45
|
+
2. super easy setup
|
46
|
+
3. support process forking without additional configuration
|
47
|
+
4. minimal performance overhead
|
47
48
|
email: tonytonyjan@gmail.com
|
48
49
|
executables:
|
49
50
|
- cover_rage
|
@@ -60,6 +61,7 @@ files:
|
|
60
61
|
- lib/cover_rage/reporters/html_reporter.rb
|
61
62
|
- lib/cover_rage/reporters/html_reporter/index.html.erb
|
62
63
|
- lib/cover_rage/reporters/json_reporter.rb
|
64
|
+
- lib/cover_rage/stores/pstore.rb
|
63
65
|
- lib/cover_rage/stores/redis.rb
|
64
66
|
- lib/cover_rage/stores/sqlite.rb
|
65
67
|
homepage: https://github.com/tonytonyjan/cover_rage
|
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
- !ruby/object:Gem::Version
|
82
84
|
version: '0'
|
83
85
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.5.23
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
89
|
summary: A Ruby production code coverage tool
|