single_cov 1.3.2 → 1.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 +4 -4
 - data/lib/single_cov.rb +24 -1
 - data/lib/single_cov/version.rb +1 -1
 - metadata +3 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6cd1fb991b879dcaf753d2aa30c4f94ac3f97659cf602df4f9adab874046c16f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c2351364b4482ceff98314b881fd5b774e9040c117479674b8fb41c0b550dac4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 813924bc4aaad528db8afe9640178f3cfad2c11ffa4042573e4810a83cf941014e3d77352436b1c999330c70c066619054b88a3117e5d87885f95ce619dfaf2d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 31915f85ff52971fb4691f1fe52680c026b8f8e70c6b390b0c538e84ced5e59b035803130f09d5df03f4eba7731608c46f02ba28df366506322559495baf588d
         
     | 
    
        data/lib/single_cov.rb
    CHANGED
    
    | 
         @@ -6,6 +6,9 @@ module SingleCov 
     | 
|
| 
       6 
6 
     | 
    
         
             
              UNCOVERED_COMMENT_MARKER = "uncovered"
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
              class << self
         
     | 
| 
      
 9 
     | 
    
         
            +
                # enable coverage reporting, changed by forking-test-runner to combine multiple reports
         
     | 
| 
      
 10 
     | 
    
         
            +
                attr_accessor :coverage_report
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       9 
12 
     | 
    
         
             
                # optionally rewrite the file we guessed with a lambda
         
     | 
| 
       10 
13 
     | 
    
         
             
                def rewrite(&block)
         
     | 
| 
       11 
14 
     | 
    
         
             
                  @rewrite = block
         
     | 
| 
         @@ -118,7 +121,11 @@ module SingleCov 
     | 
|
| 
       118 
121 
     | 
    
         
             
                  start_coverage_recording
         
     | 
| 
       119 
122 
     | 
    
         | 
| 
       120 
123 
     | 
    
         
             
                  override_at_exit do |status, _exception|
         
     | 
| 
       121 
     | 
    
         
            -
                     
     | 
| 
      
 124 
     | 
    
         
            +
                    if enabled? && main_process? && status == 0
         
     | 
| 
      
 125 
     | 
    
         
            +
                      results = coverage_results
         
     | 
| 
      
 126 
     | 
    
         
            +
                      generate_report results
         
     | 
| 
      
 127 
     | 
    
         
            +
                      exit 1 unless SingleCov.all_covered?(results)
         
     | 
| 
      
 128 
     | 
    
         
            +
                    end
         
     | 
| 
       122 
129 
     | 
    
         
             
                  end
         
     | 
| 
       123 
130 
     | 
    
         
             
                end
         
     | 
| 
       124 
131 
     | 
    
         | 
| 
         @@ -358,5 +365,21 @@ module SingleCov 
     | 
|
| 
       358 
365 
     | 
    
         
             
                def root
         
     | 
| 
       359 
366 
     | 
    
         
             
                  @root ||= (defined?(Bundler) && Bundler.root.to_s.sub(/\/gemfiles$/, '')) || Dir.pwd
         
     | 
| 
       360 
367 
     | 
    
         
             
                end
         
     | 
| 
      
 368 
     | 
    
         
            +
             
     | 
| 
      
 369 
     | 
    
         
            +
                def generate_report(results)
         
     | 
| 
      
 370 
     | 
    
         
            +
                  return unless report = coverage_report
         
     | 
| 
      
 371 
     | 
    
         
            +
             
     | 
| 
      
 372 
     | 
    
         
            +
                  # not a hard dependency for the whole library
         
     | 
| 
      
 373 
     | 
    
         
            +
                  require "json"
         
     | 
| 
      
 374 
     | 
    
         
            +
                  require "fileutils"
         
     | 
| 
      
 375 
     | 
    
         
            +
             
     | 
| 
      
 376 
     | 
    
         
            +
                  used = COVERAGES.map { |f, _| "#{root}/#{f}" }
         
     | 
| 
      
 377 
     | 
    
         
            +
                  covered = results.select { |k, _| used.include?(k) }
         
     | 
| 
      
 378 
     | 
    
         
            +
                  data = JSON.pretty_generate(
         
     | 
| 
      
 379 
     | 
    
         
            +
                    "Unit Tests" => {"coverage" => covered, "timestamp" => Time.now.to_i }
         
     | 
| 
      
 380 
     | 
    
         
            +
                  )
         
     | 
| 
      
 381 
     | 
    
         
            +
                  FileUtils.mkdir_p(File.dirname(report))
         
     | 
| 
      
 382 
     | 
    
         
            +
                  File.write report, data
         
     | 
| 
      
 383 
     | 
    
         
            +
                end
         
     | 
| 
       361 
384 
     | 
    
         
             
              end
         
     | 
| 
       362 
385 
     | 
    
         
             
            end
         
     | 
    
        data/lib/single_cov/version.rb
    CHANGED
    
    
    
        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.4.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:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-10-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            email: michael@grosser.it
         
     | 
| 
         @@ -38,8 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       38 
38 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       39 
39 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       40 
40 
     | 
    
         
             
            requirements: []
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
            rubygems_version: 2.7.6
         
     | 
| 
      
 41 
     | 
    
         
            +
            rubygems_version: 3.1.3
         
     | 
| 
       43 
42 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       44 
43 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       45 
44 
     | 
    
         
             
            summary: Actionable code coverage.
         
     |