oneshot_coverage 0.3.2 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6573e60b68c3d682f2199237df98af49b7d9bd79ff7d117bf6edc07a773b15b
4
- data.tar.gz: 0ccbec0f4e0bdfc3a807caf80be8080fb3e26ace5b261751c71d893190c4fa05
3
+ metadata.gz: 293537ff9297d5f5aa840aee43fcc4f80e01f6f386117211887be7f643b3c311
4
+ data.tar.gz: 05d17ad02efabffa178b7ca1f414bdfe131b3f4a28c62d272359f4bcf3f8e4dc
5
5
  SHA512:
6
- metadata.gz: c8003ea1b0a4c6f5b7c23e0f250735085feabbf0cf1ac61c1f82872d7ae5528ed596506ba343ea9f812e2ea63e1032cdef33c5e903319179880d1fca2bd5e617
7
- data.tar.gz: 460dab03da64b57a86986e143520dc4521ac2ebd4457d4acb23ca59cff129c66c8ed856293609ff3310d54a0b47ff658da3cc47fb1d09d86f66b8bd5569586cf
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
@@ -0,0 +1,4 @@
1
+ ## 0.4.0
2
+
3
+ - Provide options for checking bundle_path (#7)
4
+ - Fix error when empty log file is exist (#4)
data/Gemfile CHANGED
@@ -4,3 +4,8 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in oneshot_coverage.gemspec
6
6
  gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "bundler", "> 1.17"
10
+
11
+ gem "minitest", "~> 5.0"
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 onetshot mode](https://bugs.ruby-lang.org/issues/15022),
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 automatically.
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
- task :default => :spec
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]
@@ -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[@target_path.size..-1]
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: target_path_by_pathname.cleanpath.to_s + "/",
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
@@ -22,7 +22,7 @@ module OneshotCoverage
22
22
  private
23
23
 
24
24
  def fetch
25
- JSON.load(File.read(@log_path))
25
+ JSON.load(File.read(@log_path)) || {}
26
26
  rescue Errno::ENOENT
27
27
  {}
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module OneshotCoverage
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -36,7 +36,4 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  # Release ruby version lock temperary
38
38
  # spec.required_ruby_version = '>= 2.6'
39
-
40
- spec.add_development_dependency "bundler", "~> 2.1"
41
- spec.add_development_dependency "rake", "~> 13.0"
42
39
  end
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.3.2
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: 2020-08-07 00:00:00.000000000 Z
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.1.2
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: []