single_cov 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8844c5efacc57e84cf175a369a2a950800275ef5f2c239f1c1f36f287c3b203
4
- data.tar.gz: a521cbb94e444d0d8dd5c5dac776e82990a36c4b3c8c9ed90440c703fb146dbb
3
+ metadata.gz: 23e33169bc7e852c3671bd513b45a1060b1b472d51f2962e37bc2f436bf65a9e
4
+ data.tar.gz: 0715bf92881ae7b66088db7b4661b4e9b30d86ed1437d2d8a373e33e3741b727
5
5
  SHA512:
6
- metadata.gz: 16ada1719d539dba5b9e723179e4cdbc51ebe5513f964538f3f0c4a2d822aa7b167a4d9bfe16846218ab1bb7289ad0cdc4f12edeb257d20dd6b92df2e8cd0674
7
- data.tar.gz: b2fa27ac56d427e4905489fe3196c6dc25068a57c8a1133a4fbd6a5b56b7f2ef4d9514cb556fa499aa9c00654d62a56fe8540aa55e1bb932161e5324f56a8198
6
+ metadata.gz: 4554330293058a81f84444ba526183f73cdfe46a0432ca620004f2633519d160a83b94138e46f5089e8e72d1a71e3dc17a2b1afb0e1693b2c218bc22a27cd3d7
7
+ data.tar.gz: 00adfea4b2aa109ea76b9b956a448cf5958d8005cdaecfe95f699f50e8594f59faa03ea9bd409b8f197253fbe5fe881a1a1870e19fe2afabde096c77959bc74e
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SingleCov
3
- VERSION = "1.8.2"
3
+ VERSION = "1.9.0"
4
4
  end
data/lib/single_cov.rb CHANGED
@@ -4,6 +4,7 @@ module SingleCov
4
4
  MAX_OUTPUT = 40
5
5
  RAILS_APP_FOLDERS = ["models", "serializers", "helpers", "controllers", "mailers", "views", "jobs", "channels"]
6
6
  UNCOVERED_COMMENT_MARKER = /#.*uncovered/
7
+ PREFIXES_TO_IGNORE = [] # things to not prefix with lib/ etc
7
8
 
8
9
  class << self
9
10
  # enable coverage reporting: path to output file, changed by forking-test-runner at runtime to combine many reports
@@ -382,18 +383,21 @@ module SingleCov
382
383
  raise "#{file} includes neither 'test' nor 'spec' folder ... unable to resolve"
383
384
  end
384
385
 
385
- # rails things live in app
386
- file_part[0...0] = if file_part =~ /^(?:#{RAILS_APP_FOLDERS.map { |f| Regexp.escape(f) }.join('|')})\//
387
- "app/"
388
- elsif file_part.start_with?("lib/") # don't add lib twice
389
- ""
390
- else # everything else lives in lib
391
- "lib/"
392
- end
386
+ without_ignored_prefixes file_part do
387
+ # rails things live in app
388
+ file_part[0...0] =
389
+ if file_part =~ /^(?:#{RAILS_APP_FOLDERS.map { |f| Regexp.escape(f) }.join('|')})\//
390
+ "app/"
391
+ elsif file_part.start_with?("lib/") # don't add lib twice
392
+ ""
393
+ else # everything else lives in lib
394
+ "lib/"
395
+ end
393
396
 
394
- # remove test extension
395
- if !file_part.sub!(/_(?:test|spec)\.rb\b.*/, '.rb') && !file_part.sub!(/\/test_/, "/")
396
- raise "Unable to remove test extension from #{file} ... /test_, _test.rb and _spec.rb are supported"
397
+ # remove test extension
398
+ if !file_part.sub!(/_(?:test|spec)\.rb\b.*/, '.rb') && !file_part.sub!(/\/test_/, "/")
399
+ raise "Unable to remove test extension from #{file} ... /test_, _test.rb and _spec.rb are supported"
400
+ end
397
401
  end
398
402
 
399
403
  # put back the subfolder
@@ -429,5 +433,18 @@ module SingleCov
429
433
  FileUtils.mkdir_p(File.dirname(report))
430
434
  File.write report, data
431
435
  end
436
+
437
+ # file_part is modified during yield so we have to make sure to also modify in place
438
+ def without_ignored_prefixes(file_part)
439
+ folders = file_part.split('/')
440
+ return yield unless PREFIXES_TO_IGNORE.include?(folders.first)
441
+
442
+ prefix = folders.shift
443
+ file_part.replace folders.join('/')
444
+
445
+ yield
446
+
447
+ file_part[0...0] = "#{prefix}/"
448
+ end
432
449
  end
433
450
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: single_cov
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-16 00:00:00.000000000 Z
11
+ date: 2023-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it