single_cov 1.8.1 → 1.9.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 +4 -4
- data/lib/single_cov/version.rb +1 -1
- data/lib/single_cov.rb +29 -12
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 23e33169bc7e852c3671bd513b45a1060b1b472d51f2962e37bc2f436bf65a9e
         | 
| 4 | 
            +
              data.tar.gz: 0715bf92881ae7b66088db7b4661b4e9b30d86ed1437d2d8a373e33e3741b727
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4554330293058a81f84444ba526183f73cdfe46a0432ca620004f2633519d160a83b94138e46f5089e8e72d1a71e3dc17a2b1afb0e1693b2c218bc22a27cd3d7
         | 
| 7 | 
            +
              data.tar.gz: 00adfea4b2aa109ea76b9b956a448cf5958d8005cdaecfe95f699f50e8594f59faa03ea9bd409b8f197253fbe5fe881a1a1870e19fe2afabde096c77959bc74e
         | 
    
        data/lib/single_cov/version.rb
    CHANGED
    
    
    
        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. | 
| 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 | 
            -
                   | 
| 386 | 
            -
             | 
| 387 | 
            -
                     | 
| 388 | 
            -
             | 
| 389 | 
            -
             | 
| 390 | 
            -
             | 
| 391 | 
            -
             | 
| 392 | 
            -
             | 
| 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 | 
            -
             | 
| 395 | 
            -
             | 
| 396 | 
            -
             | 
| 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. | 
| 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- | 
| 11 | 
            +
            date: 2023-02-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description:
         | 
| 14 14 | 
             
            email: michael@grosser.it
         |