single_cov 1.8.2 → 1.9.1

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: 033c6118fe2eb88114dab333f21c65b789ae0841b52ecfc5d7e96ce086f1c36d
4
+ data.tar.gz: f6dbb0e79ccd6764efa21f943d1e10e31b84ba7a1bff80f4af7d92dcf3b7ea42
5
5
  SHA512:
6
- metadata.gz: 16ada1719d539dba5b9e723179e4cdbc51ebe5513f964538f3f0c4a2d822aa7b167a4d9bfe16846218ab1bb7289ad0cdc4f12edeb257d20dd6b92df2e8cd0674
7
- data.tar.gz: b2fa27ac56d427e4905489fe3196c6dc25068a57c8a1133a4fbd6a5b56b7f2ef4d9514cb556fa499aa9c00654d62a56fe8540aa55e1bb932161e5324f56a8198
6
+ metadata.gz: 939772cc7264d4ab62255b608b9ef6d493c75c6ed0e96f7e1c1d5f97e967a79bc93624c6449a5cffb5973e527a5ce9dae204e01b336e8ecb22dbea9779fd19d1
7
+ data.tar.gz: 8d101d81129a40851a00b9f7157d1e1424c0845f3f0185c64fe890b08c3f453dc11dbcd756275768d286a6817e1483205cabf18683428ecbdb884cd4877118d7
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SingleCov
3
- VERSION = "1.8.2"
3
+ VERSION = "1.9.1"
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
@@ -86,8 +87,10 @@ module SingleCov
86
87
  if missing_complete.any?
87
88
  errors << <<~MSG
88
89
  The following file(s) were previously marked as having 100% SingleCov test coverage (had no `coverage:` option) but are no longer marked as such.
89
- Please increase test coverage in these files to maintain 100% coverage and remove `coverage:` usage.
90
90
  #{missing_complete.join("\n")}
91
+ Please increase test coverage in these files to maintain 100% coverage and remove `coverage:` usage.
92
+
93
+ If this test fails during a file removal, make it pass by removing all references to the removed file's path from the code base.
91
94
  MSG
92
95
  end
93
96
 
@@ -382,18 +385,21 @@ module SingleCov
382
385
  raise "#{file} includes neither 'test' nor 'spec' folder ... unable to resolve"
383
386
  end
384
387
 
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
388
+ without_ignored_prefixes file_part do
389
+ # rails things live in app
390
+ file_part[0...0] =
391
+ if file_part =~ /^(?:#{RAILS_APP_FOLDERS.map { |f| Regexp.escape(f) }.join('|')})\//
392
+ "app/"
393
+ elsif file_part.start_with?("lib/") # don't add lib twice
394
+ ""
395
+ else # everything else lives in lib
396
+ "lib/"
397
+ end
393
398
 
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"
399
+ # remove test extension
400
+ if !file_part.sub!(/_(?:test|spec)\.rb\b.*/, '.rb') && !file_part.sub!(/\/test_/, "/")
401
+ raise "Unable to remove test extension from #{file} ... /test_, _test.rb and _spec.rb are supported"
402
+ end
397
403
  end
398
404
 
399
405
  # put back the subfolder
@@ -429,5 +435,18 @@ module SingleCov
429
435
  FileUtils.mkdir_p(File.dirname(report))
430
436
  File.write report, data
431
437
  end
438
+
439
+ # file_part is modified during yield so we have to make sure to also modify in place
440
+ def without_ignored_prefixes(file_part)
441
+ folders = file_part.split('/')
442
+ return yield unless PREFIXES_TO_IGNORE.include?(folders.first)
443
+
444
+ prefix = folders.shift
445
+ file_part.replace folders.join('/')
446
+
447
+ yield
448
+
449
+ file_part[0...0] = "#{prefix}/"
450
+ end
432
451
  end
433
452
  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.1
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-03-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it