single_cov 1.8.1 → 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: 338f545eff8f811fa678800cf39ea59209b2211ae8b6b5b49bc9f219a63ed5cd
4
- data.tar.gz: 3d2d927abde1eba8f900da08920119a94c2afa6bb856bd032215564438027147
3
+ metadata.gz: 23e33169bc7e852c3671bd513b45a1060b1b472d51f2962e37bc2f436bf65a9e
4
+ data.tar.gz: 0715bf92881ae7b66088db7b4661b4e9b30d86ed1437d2d8a373e33e3741b727
5
5
  SHA512:
6
- metadata.gz: 929684db9f9de5a13489ffe531ecde7115cb9e9102d3f70ae81a6d95e2baa7d10134e232f78c9d94a084f6e1432ab4790910ad10fe23940c4224c4b8e78a7975
7
- data.tar.gz: ca7b7d0d607ac27d16e9cf97d80c7c3f6d5c591232f2bfb2fdf576cab62ee7c66ebb7d9e1cba88b49262a54bf82ec347c7f57df3c6d78a171bc2369b9c647ed9
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.1"
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
@@ -78,7 +79,7 @@ module SingleCov
78
79
 
79
80
  def assert_full_coverage(tests: default_tests, currently_complete: [], location: nil)
80
81
  location ||= caller(0..1)[1].split(':in').first
81
- complete = tests.reject { |file| File.read(file) =~ /SingleCov.covered!(.*)uncovered:(.*)$/ }
82
+ complete = tests.select { |file| File.read(file) =~ /SingleCov.covered!(?:(?!uncovered).)*(\s*|\s*\#.*)$/ }
82
83
  missing_complete = currently_complete - complete
83
84
  newly_complete = complete - currently_complete
84
85
  errors = []
@@ -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.1
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-15 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