simplecov-small-badge 0.1 → 0.2
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/README.md +2 -1
 - data/lib/simplecov_small_badge/configuration.rb +13 -11
 - data/lib/simplecov_small_badge/formatter.rb +19 -7
 - data/lib/simplecov_small_badge/version.rb +1 -1
 - data/script/travis.sh +1 -1
 - data/simplecov-small-badge.gemspec +5 -6
 - data/spec/simplecov_small_badge_formatter_spec.rb +27 -38
 - data/spec/support/mocks.rb +23 -40
 - metadata +22 -36
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0b77c22bed299dc020a8aaf8969d02fa5e4aec211fdf2a1e383bba0b3c8086b4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: bad90c04e8c9d4b132b5404cb97b553b28a45b9d455c228fb101b31808e9fd68
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6a152639aba57094258da3921d7d5d6a984209c5b9a6456bbae45fef5e58db43469365b4e7e0eac87af6363c28d68057f7c6f4a887d5018886d36a6b9713936e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bf3853ad9dfc1a89a486a810cda5fb3596cf17ad2a456928680fc5ff8c183186b8f9eb5d682ccf982b16950126ae8dc6307824f8f48f8844753f8b94b91707b7
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,8 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # SimpleCovSmallBadge
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            [](https://badge.fury.io/rb/simplecov-small-badge)
         
     | 
| 
       3 
4 
     | 
    
         
             
            [](https://secure.travis-ci.org/MarcGrimme/simplecov-small-badge)
         
     | 
| 
       4 
5 
     | 
    
         
             
            [](https://depfu.com/github/MarcGrimme/simplecov-small-badge?project_id=6900)
         
     | 
| 
       5 
     | 
    
         
            -
            
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            *SimpleCovBadge* is a gem that can be added to the `Gemfile` and will produce a file called `coverage_badge.png` in the `coverage` directory.
         
     | 
| 
       8 
9 
     | 
    
         
             
            It could be looking as follows dependent on how it is configured.
         
     | 
| 
         @@ -8,26 +8,28 @@ module SimpleCovSmallBadge 
     | 
|
| 
       8 
8 
     | 
    
         
             
                # rubocop:disable Metrics/MethodLength
         
     | 
| 
       9 
9 
     | 
    
         
             
                def self.options
         
     | 
| 
       10 
10 
     | 
    
         
             
                  {
         
     | 
| 
       11 
     | 
    
         
            -
                    format: ' 
     | 
| 
      
 11 
     | 
    
         
            +
                    format: 'svg',
         
     | 
| 
       12 
12 
     | 
    
         
             
                    with_groups: false,
         
     | 
| 
       13 
     | 
    
         
            -
                    background: ' 
     | 
| 
      
 13 
     | 
    
         
            +
                    background: '#fff',
         
     | 
| 
       14 
14 
     | 
    
         
             
                    title_prefix: 'scov',
         
     | 
| 
       15 
     | 
    
         
            -
                    title_background: '# 
     | 
| 
       16 
     | 
    
         
            -
                     
     | 
| 
       17 
     | 
    
         
            -
                     
     | 
| 
       18 
     | 
    
         
            -
                     
     | 
| 
       19 
     | 
    
         
            -
                    coverage_background_bad: ' 
     | 
| 
       20 
     | 
    
         
            -
                    coverage_background_unknown: ' 
     | 
| 
      
 15 
     | 
    
         
            +
                    title_background: '#555',
         
     | 
| 
      
 16 
     | 
    
         
            +
                    font: 'Helvetica',
         
     | 
| 
      
 17 
     | 
    
         
            +
                    font_size: 16,
         
     | 
| 
      
 18 
     | 
    
         
            +
                    title_color: '#fff',
         
     | 
| 
      
 19 
     | 
    
         
            +
                    coverage_background_bad: '#ff0000',
         
     | 
| 
      
 20 
     | 
    
         
            +
                    coverage_background_unknown: '#cccc00',
         
     | 
| 
       21 
21 
     | 
    
         
             
                    coverage_background_good: '#4dc71f',
         
     | 
| 
       22 
22 
     | 
    
         
             
                    coverage_font: 'Helvetica-Narrow-Bold',
         
     | 
| 
       23 
     | 
    
         
            -
                    coverage_font_color: ' 
     | 
| 
      
 23 
     | 
    
         
            +
                    coverage_font_color: '#fff',
         
     | 
| 
       24 
24 
     | 
    
         
             
                    coverage_font_size: 16,
         
     | 
| 
       25 
     | 
    
         
            -
                    badge_height:  
     | 
| 
      
 25 
     | 
    
         
            +
                    badge_height: 20,
         
     | 
| 
      
 26 
     | 
    
         
            +
                    badge_width: 200,
         
     | 
| 
       26 
27 
     | 
    
         
             
                    filename_prefix: 'coverage_badge',
         
     | 
| 
       27 
28 
     | 
    
         
             
                    output_path: SimpleCov.coverage_path,
         
     | 
| 
       28 
29 
     | 
    
         
             
                    log_level: 'info',
         
     | 
| 
       29 
30 
     | 
    
         
             
                    rounded_border: true,
         
     | 
| 
       30 
     | 
    
         
            -
                    rounded_edge_radius: 3
         
     | 
| 
      
 31 
     | 
    
         
            +
                    rounded_edge_radius: 3,
         
     | 
| 
      
 32 
     | 
    
         
            +
                    percent_sign: '%'
         
     | 
| 
       31 
33 
     | 
    
         
             
                  }
         
     | 
| 
       32 
34 
     | 
    
         
             
                end
         
     | 
| 
       33 
35 
     | 
    
         
             
                # rubocop:enable Metrics/MethodLength
         
     | 
| 
         @@ -9,20 +9,29 @@ module SimpleCovSmallBadge 
     | 
|
| 
       9 
9 
     | 
    
         
             
                def initialize(output = nil)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  @output = output || STDOUT
         
     | 
| 
       11 
11 
     | 
    
         
             
                  @config = SimpleCovSmallBadge.config
         
     | 
| 
       12 
     | 
    
         
            -
                  @image = RepoSmallBadge::Image.new(map_image_config)
         
     | 
| 
       13 
12 
     | 
    
         
             
                end
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
14 
     | 
    
         
             
                def format(result)
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
                  @image. 
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  group_percent_from_result(result) do |name, title,  
     | 
| 
       20 
     | 
    
         
            -
                     
     | 
| 
      
 15 
     | 
    
         
            +
                  percent = result.source_files.covered_percent.round(0)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @image = RepoSmallBadge::Image.new(map_image_config(state(percent)))
         
     | 
| 
      
 17 
     | 
    
         
            +
                  badge('total', 'total', percent)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  group_percent_from_result(result) do |name, title, cov_percent|
         
     | 
| 
      
 19 
     | 
    
         
            +
                    badge(name, title, cov_percent.round(0))
         
     | 
| 
       21 
20 
     | 
    
         
             
                  end
         
     | 
| 
       22 
21 
     | 
    
         
             
                end
         
     | 
| 
       23 
22 
     | 
    
         | 
| 
       24 
23 
     | 
    
         
             
                private
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
                def badge(name, title, percent)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  percent_txt = percent_text(percent)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @image.config_merge(map_image_config(state(percent)))
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @image.badge(name, title, percent_txt)
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def percent_text(percent)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  "#{percent}#{@config.percent_sign}"
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       26 
35 
     | 
    
         
             
                def state(covered_percent)
         
     | 
| 
       27 
36 
     | 
    
         
             
                  if SimpleCov.minimum_coverage&.positive?
         
     | 
| 
       28 
37 
     | 
    
         
             
                    if covered_percent >= SimpleCov.minimum_coverage
         
     | 
| 
         @@ -35,9 +44,12 @@ module SimpleCovSmallBadge 
     | 
|
| 
       35 
44 
     | 
    
         
             
                  end
         
     | 
| 
       36 
45 
     | 
    
         
             
                end
         
     | 
| 
       37 
46 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                def map_image_config
         
     | 
| 
      
 47 
     | 
    
         
            +
                def map_image_config(state)
         
     | 
| 
       39 
48 
     | 
    
         
             
                  hash = {}
         
     | 
| 
       40 
49 
     | 
    
         
             
                  @config.to_hash.map do |key, value|
         
     | 
| 
      
 50 
     | 
    
         
            +
                    key = key
         
     | 
| 
      
 51 
     | 
    
         
            +
                          .to_s.sub(/^coverage_background_#{state}/, 'value_background')
         
     | 
| 
      
 52 
     | 
    
         
            +
                          .to_sym
         
     | 
| 
       41 
53 
     | 
    
         
             
                    key = key.to_s.sub(/^coverage_/, 'value_').to_sym
         
     | 
| 
       42 
54 
     | 
    
         
             
                    hash[key] = value
         
     | 
| 
       43 
55 
     | 
    
         
             
                  end
         
     | 
    
        data/script/travis.sh
    CHANGED
    
    | 
         @@ -8,5 +8,5 @@ gem install bundler-audit && bundle-audit update && bundle-audit check 
     | 
|
| 
       8 
8 
     | 
    
         
             
            gem install rubycritic && rubycritic app lib config ${RUBYCRITICPARAMS} --format console --minimum-score ${RUBYCRITICLIMIT}
         
     | 
| 
       9 
9 
     | 
    
         
             
            echo "Pushing badges upstream"
         
     | 
| 
       10 
10 
     | 
    
         
             
            [ -d badges ] || mkdir badges
         
     | 
| 
       11 
     | 
    
         
            -
            cp coverage 
     | 
| 
      
 11 
     | 
    
         
            +
            cp coverage/coverage_badge* badges/
         
     | 
| 
       12 
12 
     | 
    
         
             
            ls badges
         
     | 
| 
         @@ -16,12 +16,11 @@ Gem::Specification.new do |s| 
     | 
|
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
              s.rubyforge_project = 'simplecov-small-badge'
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              s.add_dependency ' 
     | 
| 
       20 
     | 
    
         
            -
              s.add_dependency ' 
     | 
| 
       21 
     | 
    
         
            -
              s. 
     | 
| 
       22 
     | 
    
         
            -
              s.add_development_dependency ' 
     | 
| 
       23 
     | 
    
         
            -
              s.add_development_dependency ' 
     | 
| 
       24 
     | 
    
         
            -
              s.add_development_dependency 'rubocop'
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_dependency 'repo-small-badge', '~> 0.2.1'
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_dependency 'simplecov', '~> 0.16'
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_development_dependency 'rake', '~> 12'
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_development_dependency 'rspec', '~> 3.8'
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_development_dependency 'rubocop', '~> 0.63'
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
       26 
25 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       27 
26 
     | 
    
         
             
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
         @@ -10,35 +10,30 @@ describe SimpleCovSmallBadge::Formatter do 
     | 
|
| 
       10 
10 
     | 
    
         
             
                context 'bad result' do
         
     | 
| 
       11 
11 
     | 
    
         
             
                  it do
         
     | 
| 
       12 
12 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
         
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
                                     color: 'red', coverage: '50',
         
     | 
| 
       15 
     | 
    
         
            -
                                     stack: stack)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    mock_repo_badge_image(cov: '50%', state: 'bad')
         
     | 
| 
       16 
14 
     | 
    
         
             
                    result = mock_result(50)
         
     | 
| 
       17 
15 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       18 
16 
     | 
    
         
             
                  end
         
     | 
| 
       19 
17 
     | 
    
         
             
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       20 
19 
     | 
    
         
             
                context 'good result' do
         
     | 
| 
       21 
20 
     | 
    
         
             
                  it do
         
     | 
| 
       22 
21 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(100)
         
     | 
| 
       23 
     | 
    
         
            -
                     
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                                                      stack: stack))
         
     | 
| 
       29 
     | 
    
         
            -
                    result = mock_result(100, 'library': mock_result_group(100))
         
     | 
| 
      
 22 
     | 
    
         
            +
                    image_mock = mock_repo_badge_image(title: 'total', name: 'total',
         
     | 
| 
      
 23 
     | 
    
         
            +
                                                       cov: '100%')
         
     | 
| 
      
 24 
     | 
    
         
            +
                    mock_repo_badge_image(title: 'library', name: 'library',
         
     | 
| 
      
 25 
     | 
    
         
            +
                                          cov: '100%', mock: image_mock)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    result = mock_result(100, 'library' => mock_result_group(100))
         
     | 
| 
       30 
27 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       31 
28 
     | 
    
         
             
                  end
         
     | 
| 
       32 
29 
     | 
    
         | 
| 
       33 
30 
     | 
    
         
             
                  it do
         
     | 
| 
       34 
31 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
         
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                                                      stack: stack))
         
     | 
| 
       41 
     | 
    
         
            -
                    result = mock_result(90, 'library': mock_result_group(90))
         
     | 
| 
      
 32 
     | 
    
         
            +
                    image_mock = mock_repo_badge_image(title: 'total', name: 'total',
         
     | 
| 
      
 33 
     | 
    
         
            +
                                                       cov: '90%')
         
     | 
| 
      
 34 
     | 
    
         
            +
                    mock_repo_badge_image(title: 'library', name: 'library',
         
     | 
| 
      
 35 
     | 
    
         
            +
                                          cov: '90%', mock: image_mock)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    result = mock_result(90, 'library' => mock_result_group(90))
         
     | 
| 
       42 
37 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       43 
38 
     | 
    
         
             
                  end
         
     | 
| 
       44 
39 
     | 
    
         
             
                end
         
     | 
| 
         @@ -46,13 +41,11 @@ describe SimpleCovSmallBadge::Formatter do 
     | 
|
| 
       46 
41 
     | 
    
         
             
                context 'bad result' do
         
     | 
| 
       47 
42 
     | 
    
         
             
                  it do
         
     | 
| 
       48 
43 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(91)
         
     | 
| 
       49 
     | 
    
         
            -
                     
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                                                      stack: stack))
         
     | 
| 
       55 
     | 
    
         
            -
                    result = mock_result(90, 'library': mock_result_group(90))
         
     | 
| 
      
 44 
     | 
    
         
            +
                    image_mock = mock_repo_badge_image(title: 'total', name: 'total',
         
     | 
| 
      
 45 
     | 
    
         
            +
                                                       cov: '90%', state: 'bad')
         
     | 
| 
      
 46 
     | 
    
         
            +
                    mock_repo_badge_image(title: 'library', name: 'library',
         
     | 
| 
      
 47 
     | 
    
         
            +
                                          cov: '90%', state: 'bad', mock: image_mock)
         
     | 
| 
      
 48 
     | 
    
         
            +
                    result = mock_result(90, 'library' => mock_result_group(90))
         
     | 
| 
       56 
49 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       57 
50 
     | 
    
         
             
                  end
         
     | 
| 
       58 
51 
     | 
    
         
             
                end
         
     | 
| 
         @@ -60,13 +53,11 @@ describe SimpleCovSmallBadge::Formatter do 
     | 
|
| 
       60 
53 
     | 
    
         
             
                context 'unknown result' do
         
     | 
| 
       61 
54 
     | 
    
         
             
                  it do
         
     | 
| 
       62 
55 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(nil)
         
     | 
| 
       63 
     | 
    
         
            -
                     
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                                                      stack: stack))
         
     | 
| 
       69 
     | 
    
         
            -
                    result = mock_result(90, 'library': mock_result_group(90))
         
     | 
| 
      
 56 
     | 
    
         
            +
                    image_mock = mock_repo_badge_image(title: 'total', name: 'total',
         
     | 
| 
      
 57 
     | 
    
         
            +
                                                       cov: '90%', state: 'unknown')
         
     | 
| 
      
 58 
     | 
    
         
            +
                    mock_repo_badge_image(title: 'library', name: 'library',
         
     | 
| 
      
 59 
     | 
    
         
            +
                                          cov: '90%', state: 'unknown', mock: image_mock)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    result = mock_result(90, 'library' => mock_result_group(90))
         
     | 
| 
       70 
61 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       71 
62 
     | 
    
         
             
                  end
         
     | 
| 
       72 
63 
     | 
    
         
             
                end
         
     | 
| 
         @@ -74,13 +65,11 @@ describe SimpleCovSmallBadge::Formatter do 
     | 
|
| 
       74 
65 
     | 
    
         
             
                context 'mixed result' do
         
     | 
| 
       75 
66 
     | 
    
         
             
                  it do
         
     | 
| 
       76 
67 
     | 
    
         
             
                    allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
         
     | 
| 
       77 
     | 
    
         
            -
                     
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                                                      stack: stack))
         
     | 
| 
       83 
     | 
    
         
            -
                    result = mock_result(89, 'library': mock_result_group(90))
         
     | 
| 
      
 68 
     | 
    
         
            +
                    image_mock = mock_repo_badge_image(title: 'total', name: 'total',
         
     | 
| 
      
 69 
     | 
    
         
            +
                                                       cov: '89%', state: 'bad')
         
     | 
| 
      
 70 
     | 
    
         
            +
                    mock_repo_badge_image(title: 'library', name: 'library',
         
     | 
| 
      
 71 
     | 
    
         
            +
                                          cov: '90%', state: 'good', mock: image_mock)
         
     | 
| 
      
 72 
     | 
    
         
            +
                    result = mock_result(89, 'library' => mock_result_group(90))
         
     | 
| 
       84 
73 
     | 
    
         
             
                    expect(subject.format(result)).to be_truthy
         
     | 
| 
       85 
74 
     | 
    
         
             
                  end
         
     | 
| 
       86 
75 
     | 
    
         
             
                end
         
     | 
    
        data/spec/support/mocks.rb
    CHANGED
    
    | 
         @@ -2,50 +2,33 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module TestSimpleCovSmallBadge
         
     | 
| 
       4 
4 
     | 
    
         
             
              module Mocks
         
     | 
| 
       5 
     | 
    
         
            -
                # rubocop:disable Metrics/ 
     | 
| 
       6 
     | 
    
         
            -
                def  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
                # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize
         
     | 
| 
      
 6 
     | 
    
         
            +
                def mock_repo_badge_image(cov: 100, name: 'total',
         
     | 
| 
      
 7 
     | 
    
         
            +
                                          title: 'total',
         
     | 
| 
      
 8 
     | 
    
         
            +
                                          state: 'good',
         
     | 
| 
      
 9 
     | 
    
         
            +
                                          config: {},
         
     | 
| 
      
 10 
     | 
    
         
            +
                                          mock: instance_double('Image'))
         
     | 
| 
      
 11 
     | 
    
         
            +
                  config = map_config_options(config, state)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  allow(RepoSmallBadge::Image).to receive(:new)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    .with(config).and_return(mock)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  allow(mock).to receive(:config_merge).with(config).and_return(config)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  allow(mock).to receive(:badge).with(name, title, cov)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  mock
         
     | 
| 
       10 
17 
     | 
    
         
             
                end
         
     | 
| 
       11 
     | 
    
         
            -
                # rubocop:enable Metrics/ 
     | 
| 
      
 18 
     | 
    
         
            +
                # rubocop:enable Metrics/ParameterLists, Metrics/AbcSize
         
     | 
| 
       12 
19 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                  allow(stack).to receive(:stack).and_yield(stack)
         
     | 
| 
       23 
     | 
    
         
            -
                  stack
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
                # rubocop:enable Metrics/LineLength, Metrics/AbcSize
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
       28 
     | 
    
         
            -
                def mock_mini_magick(**keys)
         
     | 
| 
       29 
     | 
    
         
            -
                  keys[:convert] ||= instance_double('Convert')
         
     | 
| 
       30 
     | 
    
         
            -
                  convert = keys[:convert]
         
     | 
| 
       31 
     | 
    
         
            -
                  pango_text = pango_text_match(keys[:title], keys[:color], keys[:coverage])
         
     | 
| 
       32 
     | 
    
         
            -
                  allow(MiniMagick::Tool::Convert)
         
     | 
| 
       33 
     | 
    
         
            -
                    .to receive(:new).and_yield(keys[:convert])
         
     | 
| 
       34 
     | 
    
         
            -
                  allow(convert).to receive(:gravity).with('center')
         
     | 
| 
       35 
     | 
    
         
            -
                  allow(convert).to receive(:background).with('transparent')
         
     | 
| 
       36 
     | 
    
         
            -
                  allow(convert).to receive(:pango).with(pango_text)
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  if keys.fetch(:rounded_border, true)
         
     | 
| 
       39 
     | 
    
         
            -
                    allow(convert).to receive(:stack).and_yield(keys[:stack])
         
     | 
| 
       40 
     | 
    
         
            -
                    allow(convert).to receive(:compose).with('CopyOpacity')
         
     | 
| 
       41 
     | 
    
         
            -
                    allow(convert).to receive(:alpha).with('off')
         
     | 
| 
       42 
     | 
    
         
            -
                    allow(convert).to receive(:composite)
         
     | 
| 
      
 20 
     | 
    
         
            +
                def map_config_options(config_hash, state)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  hash = {}
         
     | 
| 
      
 22 
     | 
    
         
            +
                  SimpleCovSmallBadge::Configuration.options.merge(config_hash)
         
     | 
| 
      
 23 
     | 
    
         
            +
                                                    .map do |key, value|
         
     | 
| 
      
 24 
     | 
    
         
            +
                    key = key.to_s
         
     | 
| 
      
 25 
     | 
    
         
            +
                             .sub(/^coverage_background_#{state}/, 'value_background')
         
     | 
| 
      
 26 
     | 
    
         
            +
                             .to_sym
         
     | 
| 
      
 27 
     | 
    
         
            +
                    key = key.to_s.sub(/^coverage_/, 'value_').to_sym
         
     | 
| 
      
 28 
     | 
    
         
            +
                    hash[key] = value
         
     | 
| 
       43 
29 
     | 
    
         
             
                  end
         
     | 
| 
       44 
     | 
    
         
            -
                   
     | 
| 
       45 
     | 
    
         
            -
                    .with("#{SimpleCov.coverage_path}/coverage_badge_#{keys[:name]}.png")
         
     | 
| 
       46 
     | 
    
         
            -
                  convert
         
     | 
| 
      
 30 
     | 
    
         
            +
                  hash
         
     | 
| 
       47 
31 
     | 
    
         
             
                end
         
     | 
| 
       48 
     | 
    
         
            -
                # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
         
     | 
| 
       49 
32 
     | 
    
         | 
| 
       50 
33 
     | 
    
         
             
                def mock_result(total_cov, groups_hash = {})
         
     | 
| 
       51 
34 
     | 
    
         
             
                  result_double = instance_double('Result')
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,99 +1,85 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: simplecov-small-badge
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: '0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: '0.2'
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Marc Grimme
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-02-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
     | 
    
         
            -
              name: mini_magick
         
     | 
| 
       15 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
     | 
    
         
            -
                requirements:
         
     | 
| 
       17 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       18 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       20 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       21 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       22 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
     | 
    
         
            -
                requirements:
         
     | 
| 
       24 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       25 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       27 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
14 
     | 
    
         
             
              name: repo-small-badge
         
     | 
| 
       29 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       32 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version:  
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 0.2.1
         
     | 
| 
       34 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       39 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version:  
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 0.2.1
         
     | 
| 
       41 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
28 
     | 
    
         
             
              name: simplecov
         
     | 
| 
       43 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       46 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0.16'
         
     | 
| 
       48 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - - " 
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       53 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0.16'
         
     | 
| 
       55 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
42 
     | 
    
         
             
              name: rake
         
     | 
| 
       57 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - - " 
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       60 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '12'
         
     | 
| 
       62 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       63 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       66 
     | 
    
         
            -
                - - " 
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       67 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '12'
         
     | 
| 
       69 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       70 
56 
     | 
    
         
             
              name: rspec
         
     | 
| 
       71 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       72 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       73 
     | 
    
         
            -
                - - " 
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       74 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       75 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '3.8'
         
     | 
| 
       76 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       77 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       78 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       79 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
       80 
     | 
    
         
            -
                - - " 
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       81 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       82 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '3.8'
         
     | 
| 
       83 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       84 
70 
     | 
    
         
             
              name: rubocop
         
     | 
| 
       85 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       86 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       87 
     | 
    
         
            -
                - - " 
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       88 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       89 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0.63'
         
     | 
| 
       90 
76 
     | 
    
         
             
              type: :development
         
     | 
| 
       91 
77 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       92 
78 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       93 
79 
     | 
    
         
             
                requirements:
         
     | 
| 
       94 
     | 
    
         
            -
                - - " 
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       95 
81 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0.63'
         
     | 
| 
       97 
83 
     | 
    
         
             
            description: Small Badge generator for SimpleCov coverage tool for ruby
         
     | 
| 
       98 
84 
     | 
    
         
             
            email:
         
     | 
| 
       99 
85 
     | 
    
         
             
            - marc.grimme at gmail dot com
         
     |