oneshot_coverage 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +19 -0
- data/CHANGELOG +4 -0
- data/Gemfile +5 -0
- data/README.md +3 -2
- data/Rakefile +11 -1
- data/lib/oneshot_coverage.rb +11 -11
- data/lib/oneshot_coverage/logger/file_logger.rb +1 -1
- data/lib/oneshot_coverage/version.rb +1 -1
- data/oneshot_coverage.gemspec +0 -3
- metadata +9 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 293537ff9297d5f5aa840aee43fcc4f80e01f6f386117211887be7f643b3c311
|
4
|
+
data.tar.gz: 05d17ad02efabffa178b7ca1f414bdfe131b3f4a28c62d272359f4bcf3f8e4dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555c67956799e0fd4284360938c64d41c3aea1b829306ef2e5d0a7308134694ccaa3250e591dd953ab8e816f4f62dcb53e49ddc120777ce92239ea1f47f4369a
|
7
|
+
data.tar.gz: fe81e8fc2256a7b1792eb13719f6958a1a67198ed4082cf1f2821cf7f19f3f5f17875620b7aa6446ced775b0956806e38823faa599655f787e5f47c5ba724f35
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
11
|
+
name: Test on Ruby ${{ matrix.ruby }}
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: ${{ matrix.ruby }}
|
17
|
+
bundler-cache: true
|
18
|
+
- name: Execute test
|
19
|
+
run: bundle exec rake
|
data/CHANGELOG
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# OneshotCoverage
|
2
2
|
|
3
|
-
This gem may not be very useful when you want to use [Coverage
|
3
|
+
This gem may not be very useful when you want to use [Coverage oneshot mode](https://bugs.ruby-lang.org/issues/15022),
|
4
4
|
however, It could be good example to study how to implement by yourself.
|
5
5
|
|
6
6
|
This gem provides simple tools to use oneshot mode easier. It gives you:
|
@@ -9,7 +9,7 @@ This gem provides simple tools to use oneshot mode easier. It gives you:
|
|
9
9
|
- Pluggable logger interface
|
10
10
|
|
11
11
|
Please notice that it records code executions under the target path(usually, project base path).
|
12
|
-
If you have bundle gem path under target path, It will be ignored
|
12
|
+
If you have bundle gem path under target path, It will be ignored by default.
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -36,6 +36,7 @@ OneshotCoverage.configure(
|
|
36
36
|
target_path: '/base/project/path',
|
37
37
|
logger: OneshotCoverage::Logger::NullLogger.new,
|
38
38
|
emit_term: nil, # emit per `emit_term` seconds. It tries to emit per request when `nil`.
|
39
|
+
cover_bundle_path: false, # record bundle gem path. Default value is false.
|
39
40
|
)
|
40
41
|
OneshotCoverage.start
|
41
42
|
```
|
data/Rakefile
CHANGED
@@ -1,2 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
2
|
-
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: %i[test]
|
data/lib/oneshot_coverage.rb
CHANGED
@@ -22,7 +22,7 @@ module OneshotCoverage
|
|
22
22
|
OneshotLog = Struct.new(:path, :md5_hash, :lines)
|
23
23
|
|
24
24
|
class Reporter
|
25
|
-
def initialize(target_path:, logger:, emit_term: nil)
|
25
|
+
def initialize(target_path:, logger:, emit_term: nil, cover_bundle_path: false)
|
26
26
|
@target_path = target_path
|
27
27
|
@logger = logger
|
28
28
|
@emit_term = emit_term
|
@@ -32,6 +32,7 @@ module OneshotCoverage
|
|
32
32
|
|
33
33
|
if defined?(Bundler)
|
34
34
|
@bundler_path = Bundler.bundle_path.to_s
|
35
|
+
@cover_bundle_path = cover_bundle_path
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -69,13 +70,17 @@ module OneshotCoverage
|
|
69
70
|
|
70
71
|
def is_target?(filepath, value)
|
71
72
|
return false if value[:oneshot_lines].empty?
|
73
|
+
return @cover_bundle_path if @bundler_path && filepath.start_with?(@bundler_path)
|
72
74
|
return false if !filepath.start_with?(@target_path)
|
73
|
-
return false if @bundler_path && filepath.start_with?(@bundler_path)
|
74
75
|
true
|
75
76
|
end
|
76
77
|
|
77
78
|
def relative_path(filepath)
|
78
|
-
filepath
|
79
|
+
if filepath.include?(@target_path)
|
80
|
+
filepath[@target_path.size..-1]
|
81
|
+
else
|
82
|
+
filepath
|
83
|
+
end
|
79
84
|
end
|
80
85
|
|
81
86
|
def md5_hash_cache
|
@@ -106,17 +111,12 @@ module OneshotCoverage
|
|
106
111
|
@reporter&.emit(force_emit)
|
107
112
|
end
|
108
113
|
|
109
|
-
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new, emit_term: nil)
|
110
|
-
target_path_by_pathname =
|
111
|
-
if target_path.is_a? Pathname
|
112
|
-
target_path
|
113
|
-
else
|
114
|
-
Pathname.new(target_path)
|
115
|
-
end
|
114
|
+
def configure(target_path:, logger: OneshotCoverage::Logger::NullLogger.new, emit_term: nil, cover_bundle_path: false)
|
116
115
|
@reporter = OneshotCoverage::Reporter.new(
|
117
|
-
target_path:
|
116
|
+
target_path: Pathname.new(target_path).cleanpath.to_s + "/",
|
118
117
|
logger: logger,
|
119
118
|
emit_term: emit_term,
|
119
|
+
cover_bundle_path: cover_bundle_path
|
120
120
|
)
|
121
121
|
end
|
122
122
|
end
|
data/oneshot_coverage.gemspec
CHANGED
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneshot_coverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shia
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.1'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '13.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '13.0'
|
11
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
41
13
|
description: OneshotCoverage will help you to measure oneshot coverage on production
|
42
14
|
email:
|
43
15
|
- rise.shia@gmail.com
|
@@ -45,7 +17,9 @@ executables: []
|
|
45
17
|
extensions: []
|
46
18
|
extra_rdoc_files: []
|
47
19
|
files:
|
20
|
+
- ".github/workflows/main.yml"
|
48
21
|
- ".gitignore"
|
22
|
+
- CHANGELOG
|
49
23
|
- CODE_OF_CONDUCT.md
|
50
24
|
- Gemfile
|
51
25
|
- LICENSE.txt
|
@@ -67,7 +41,7 @@ metadata:
|
|
67
41
|
homepage_uri: https://github.com/riseshia/oneshot_coverage
|
68
42
|
source_code_uri: https://github.com/riseshia/oneshot_coverage
|
69
43
|
changelog_uri: https://github.com/riseshia/oneshot_coverage
|
70
|
-
post_install_message:
|
44
|
+
post_install_message:
|
71
45
|
rdoc_options: []
|
72
46
|
require_paths:
|
73
47
|
- lib
|
@@ -82,8 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
56
|
- !ruby/object:Gem::Version
|
83
57
|
version: '0'
|
84
58
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
86
|
-
signing_key:
|
59
|
+
rubygems_version: 3.2.3
|
60
|
+
signing_key:
|
87
61
|
specification_version: 4
|
88
62
|
summary: Simple toolbox for oneshot coverage
|
89
63
|
test_files: []
|