simplecov-small-badge 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6cda28fa5acf4a144d0c11620b9bf580154e9229401a79bddb78f15930cefe81
4
+ data.tar.gz: 4792e1b6e9bbac3887e9e97ed4e1a1eaddb405c736b5af87dfe19cb33b3da91b
5
+ SHA512:
6
+ metadata.gz: 6bf1b6d227a5e57356c4a1d1ea7df521c7118f91f0f37d53e06cd0a9160b53280c163a185469fc23473bb67d6728500aa85eaed7886558ed09f6144cdf31a032
7
+ data.tar.gz: 29c7c74b841243ba08e8c724d0dac233e795ad30f4e168e6a3d42ed5171597aa4ba0e00f913cb8e951e1b495cbc2d89647d06366866197785dffd6592a2757a3
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ .rvmrc
2
+ .bundle
3
+ Gemfile.lock
4
+
5
+ ## PROJECT::GENERAL
6
+ coverage
7
+ rdoc
8
+ pkg
9
+ .sass-cache
10
+ *.gem
11
+
12
+ ## PROJECT::SPECIFIC
13
+
14
+ vendor
15
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ Metrics/ModuleLength:
2
+ Exclude:
3
+ - "spec/*_spec.rb"
4
+
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - "spec/*_spec.rb"
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ simplecov-small-badge
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ branches:
3
+ only:
4
+ - master
5
+ rvm:
6
+ - 2.5.1
7
+ cache: bundler
8
+ bundler_args: "--jobs=3 --retry=3 --without production"
9
+ matrix:
10
+ fast_finish: true
11
+ script:
12
+ - sh script/travis.sh
13
+ deploy:
14
+ provider: pages
15
+ skip-cleanup: true
16
+ github-token: $GITHUB_TOKEN
17
+ keep-history: true
18
+ verbose: true
19
+ on:
20
+ branch: master
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'byebug', group: %i[development test]
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Marc Grimme
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # SimpleCovSmallBadge
2
+
3
+ [![Build Status](https://api.travis-ci.org/MarcGrimme/simplecov-small-badge.svg?branch=master)](https://secure.travis-ci.org/MarcGrimme/simplecov-small-badge)
4
+ [![Depfu](https://badges.depfu.com/badges/48a6c1c7c649f62eede6ffa2be843180/count.svg)](https://depfu.com/github/MarcGrimme/simplecov-small-badge?project_id=6900)
5
+ ![Coverage](https://marcgrimme.github.io/simplecov-small-badge/badges/coverage_badge_total.png)
6
+
7
+ *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
+ It could be looking as follows dependent on how it is configured.
9
+
10
+ ...
11
+
12
+ The idea is to created a badge for [SimpleCov](https://github.com/colszowka/simplecov) to create a persistable image that shows the coverage in percent as a badge.
13
+
14
+ ## Installation
15
+
16
+ The badge creation is dependent on the [MiniMagic gem](https://github.com/colszowka/simplecov) which requires the [ImageMagick](http://www.imagemagick.org/index.php) software.
17
+ It can be installed in your Ruby library or rails app as part of the `Gemfile` as follows.
18
+
19
+ ```
20
+ # In your gemfile
21
+ gem 'simplecov-small-badge', :require => false
22
+ ```
23
+
24
+ This gem is an alternative and inspired by the great work in the other gem [simplecov-badge](https://github.com/matthew342/simplecov-badge) which does a similar badge but looks different and cannot easily made small. So it's mostly an optical alternative.
25
+
26
+ ## Usage
27
+
28
+ Whereever you are integrating `SimpleCov` you can configure the `SimpleCovSmallBadge` gem as any formater can be configured. The default integration could looks as follows:
29
+
30
+ ```
31
+ # Wherever your SimpleCov.start block is (spec_helper.rb, test_helper.rb, or .simplecov)
32
+ SimpleCov.start do
33
+ require 'simple-cov-small-badge'
34
+ # add your normal SimpleCov configs
35
+ add_filter "/app/model"
36
+ # configure any options you want for SimpleCov::Formatter::BadgeFormatter
37
+ SimpleCovSmallBadge.configure do |config|
38
+ # switches on logging for convert
39
+ config.log_level = 'debug'
40
+ # does not created rounded borders
41
+ config.rounded_border = false
42
+ # set the background for the title to darkgrey
43
+ config.background_color = 'darkgrey'
44
+ end
45
+ # call SimpleCov::Formatter::BadgeFormatter after the normal HTMLFormatter
46
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
47
+ SimpleCov::Formatter::HTMLFormatter,
48
+ SimpleCovSimpleBadge::Formatter,
49
+ ]
50
+ end
51
+ ```
52
+
53
+ ## Integration into Travis-CI via github-pages
54
+
55
+ This process is split into two steps.
56
+
57
+ 1. You need to create an access token for you github repository that can be configured to travis to allow password-less pushing. This is described in [Github Help - Authenticating to GitHub / Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
58
+
59
+ 2. Configure travis to push the result to github-pages inspired from [the Travis description](https://docs.travis-ci.com/user/deployment/pages/) and configuration to be found in [.travis.yml](.travis.yml)
60
+
61
+ 3. Integrate your badge into the README.md as follows ``![Coverage](https://marcgrimme.github.io/simplecov-small-badge/badges/coverage_badge_total.png)``
62
+
63
+ ## Configuration Options
64
+
65
+ The behaviour of `SimpleCovSmallBadge` can be influenced by configuration options as defined in the [configuration class](lib/simplecov_small_badge/configuration.rb).
66
+
67
+ ## Development
68
+
69
+ After checking out the repo, run `bundle update` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
+
73
+ ## Contributing
74
+
75
+ 1. Fork it ( https://github.com/marcgrimme/simplecov-small-badge/fork )
76
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
77
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
78
+ 4. Push to the branch (`git push origin my-new-feature`)
79
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new('spec')
8
+
9
+ # If you want to make this the default task
10
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'simplecov_small_badge'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ # setup the environment
15
+ config = SimpleCovSmallBadge::Configuration.new
16
+ # rubocop:disable Style/GlobalVars
17
+ $image = SimpleCovSmallBadge::Image.new(config)
18
+ # rubocop:enable Style/GlobalVars
19
+
20
+ require 'irb'
21
+ IRB.start
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Ensure we are using a compatible version of SimpleCov
4
+ # :nocov:
5
+ if defined?(SimpleCov::VERSION) &&
6
+ Gem::Version.new(SimpleCov::VERSION) < Gem::Version.new('0.7.1')
7
+ raise 'The version of SimpleCov you are using is too old. '\
8
+ 'Please update with `gem install simplecov` or `bundle update simplecov`'
9
+ end
10
+ # :nocov:
11
+
12
+ require 'simplecov_small_badge/configuration'
13
+ # :nodoc:
14
+ module SimpleCovSmallBadge
15
+ @configuration = Configuration.new
16
+ def self.configure
17
+ yield config
18
+ end
19
+
20
+ def self.config
21
+ @configuration
22
+ end
23
+ end
24
+
25
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
26
+ require 'simplecov_small_badge/version'
27
+ require 'simplecov_small_badge/formatter'
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCovSmallBadge
4
+ # Class to keep all the valid documentations that are required to build the
5
+ # badge
6
+ class Configuration
7
+ # Set up config variables.
8
+ # rubocop:disable Metrics/MethodLength
9
+ def self.options
10
+ {
11
+ format: 'png',
12
+ with_groups: false,
13
+ background: 'transparent',
14
+ title_prefix: 'scov',
15
+ title_background: '#595959',
16
+ title_font: 'Helvetica',
17
+ title_font_size: 16,
18
+ title_font_color: 'white',
19
+ coverage_background_bad: 'red',
20
+ coverage_background_unknown: 'yellow',
21
+ coverage_background_good: '#4dc71f',
22
+ coverage_font: 'Helvetica-Narrow-Bold',
23
+ coverage_font_color: 'white',
24
+ coverage_font_size: 16,
25
+ badge_height: 30,
26
+ filename_prefix: 'coverage_badge',
27
+ output_path: SimpleCov.coverage_path,
28
+ log_level: 'info',
29
+ rounded_border: true,
30
+ rounded_edge_radius: 3
31
+ }
32
+ end
33
+ # rubocop:enable Metrics/MethodLength
34
+
35
+ # set up class variables and getters/setters
36
+ options.keys.each do |opt|
37
+ define_method(opt) { instance_variable_get "@#{opt}" }
38
+ define_method("#{opt}=") { |val| instance_variable_set("@#{opt}", val) }
39
+ end
40
+
41
+ def initialize(**opts)
42
+ SimpleCovSmallBadge::Configuration
43
+ .options.merge(opts).each { |opt, v| send(:"#{opt}=", v) }
44
+ end
45
+
46
+ def to_hash
47
+ hash = {}
48
+ instance_variables.each do |var|
49
+ hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
50
+ end
51
+ hash
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'repo_small_badge/image'
4
+ require 'simplecov_small_badge/configuration'
5
+
6
+ module SimpleCovSmallBadge
7
+ # Basic Badge Formater Class that creates the badges.
8
+ class Formatter
9
+ def initialize(output = nil)
10
+ @output = output || STDOUT
11
+ @config = SimpleCovSmallBadge.config
12
+ @image = RepoSmallBadge::Image.new(map_image_config)
13
+ end
14
+
15
+ def format(result)
16
+ covered_percent = result.source_files.covered_percent.round(0)
17
+ @image.badge('total', 'total', covered_percent,
18
+ state(covered_percent))
19
+ group_percent_from_result(result) do |name, title, percent|
20
+ @image.badge(name, title, percent, state(percent))
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def state(covered_percent)
27
+ if SimpleCov.minimum_coverage&.positive?
28
+ if covered_percent >= SimpleCov.minimum_coverage
29
+ 'good'
30
+ else
31
+ 'bad'
32
+ end
33
+ else
34
+ 'unknown'
35
+ end
36
+ end
37
+
38
+ def map_image_config
39
+ hash = {}
40
+ @config.to_hash.map do |key, value|
41
+ key = key.to_s.sub(/^coverage_/, 'value_').to_sym
42
+ hash[key] = value
43
+ end
44
+ hash
45
+ end
46
+
47
+ # converts the result to a hash consisting of the groupname
48
+ # array of percentage (integer in percent), strength float
49
+ # and the state [ 'good', 'bad', 'unknown' ]
50
+ # consolidated for each group.
51
+ def group_percent_from_result(result)
52
+ result.groups.each do |name, files|
53
+ covered = files.covered_percent.round(0)
54
+ yield name, name, covered, covered
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCovSmallBadge
4
+ VERSION = '0.1'
5
+ end
data/script/travis.sh ADDED
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ set -e
3
+ RUBYCRITICLIMIT=${RUBYCRITICLIMIT:-"90.0"}
4
+
5
+ bundle exec rspec
6
+ bundle exec rubocop
7
+ gem install bundler-audit && bundle-audit update && bundle-audit check
8
+ gem install rubycritic && rubycritic app lib config ${RUBYCRITICPARAMS} --format console --minimum-score ${RUBYCRITICLIMIT}
9
+ echo "Pushing badges upstream"
10
+ [ -d badges ] || mkdir badges
11
+ cp coverage/*.png badges/
12
+ ls badges
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+ require 'simplecov_small_badge/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'simplecov-small-badge'
8
+ s.version = SimpleCovSmallBadge::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ['Marc Grimme']
11
+ s.email = ['marc.grimme at gmail dot com']
12
+ s.license = 'MIT'
13
+ s.homepage = 'https://github.com/marcgrimme/simplecov-small-badge'
14
+ s.summary = %(Small Badge generator for SimpleCov coverage tool for ruby)
15
+ s.description = %(Small Badge generator for SimpleCov coverage tool for ruby)
16
+
17
+ s.rubyforge_project = 'simplecov-small-badge'
18
+
19
+ s.add_dependency 'mini_magick'
20
+ s.add_dependency 'repo-small-badge'
21
+ s.add_dependency 'simplecov'
22
+ s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'rspec'
24
+ s.add_development_dependency 'rubocop'
25
+
26
+ s.files = `git ls-files`.split("\n")
27
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28
+ s.executables = `git ls-files -- bin/*`
29
+ .split("\n").map { |f| File.basename(f) }
30
+ s.require_paths = ['lib']
31
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SimpleCovSmallBadge::Configuration do
6
+ described_class.options.each do |opt, value|
7
+ context "\##{opt}" do
8
+ it { expect(subject.send(opt)).to eq(value) }
9
+ end
10
+ end
11
+
12
+ context '#to_hash' do
13
+ it { expect(subject.to_hash).to eq(described_class.options) }
14
+ end
15
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe SimpleCovSmallBadge::Formatter do
6
+ include TestSimpleCovSmallBadge::Mocks
7
+
8
+ let(:stack) { mock_mini_magick_stack }
9
+ describe '#format' do
10
+ context 'bad result' do
11
+ it do
12
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
13
+ mock_mini_magick(name: 'total', title: 'scov total',
14
+ color: 'red', coverage: '50',
15
+ stack: stack)
16
+ result = mock_result(50)
17
+ expect(subject.format(result)).to be_truthy
18
+ end
19
+ end
20
+ context 'good result' do
21
+ it do
22
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(100)
23
+ mock_mini_magick(name: 'library', title: 'scov library',
24
+ color: '#4dc71f', coverage: '100',
25
+ stack: stack, convert:
26
+ mock_mini_magick(name: 'total', title: 'scov total',
27
+ color: '#4dc71f', coverage: '100',
28
+ stack: stack))
29
+ result = mock_result(100, 'library': mock_result_group(100))
30
+ expect(subject.format(result)).to be_truthy
31
+ end
32
+
33
+ it do
34
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
35
+ mock_mini_magick(name: 'library', title: 'scov library',
36
+ color: '#4dc71f', coverage: '90',
37
+ stack: stack, convert:
38
+ mock_mini_magick(name: 'total', title: 'scov total',
39
+ color: '#4dc71f', coverage: '90',
40
+ stack: stack))
41
+ result = mock_result(90, 'library': mock_result_group(90))
42
+ expect(subject.format(result)).to be_truthy
43
+ end
44
+ end
45
+
46
+ context 'bad result' do
47
+ it do
48
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(91)
49
+ mock_mini_magick(name: 'library', title: 'scov library',
50
+ color: 'red', coverage: '90',
51
+ stack: stack, convert:
52
+ mock_mini_magick(name: 'total', title: 'scov total',
53
+ color: 'red', coverage: '90',
54
+ stack: stack))
55
+ result = mock_result(90, 'library': mock_result_group(90))
56
+ expect(subject.format(result)).to be_truthy
57
+ end
58
+ end
59
+
60
+ context 'unknown result' do
61
+ it do
62
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(nil)
63
+ mock_mini_magick(name: 'library', title: 'scov library',
64
+ color: 'yellow', coverage: '90',
65
+ stack: stack, convert:
66
+ mock_mini_magick(name: 'total', title: 'scov total',
67
+ color: 'yellow', coverage: '90',
68
+ stack: stack))
69
+ result = mock_result(90, 'library': mock_result_group(90))
70
+ expect(subject.format(result)).to be_truthy
71
+ end
72
+ end
73
+
74
+ context 'mixed result' do
75
+ it do
76
+ allow(SimpleCov).to receive(:minimum_coverage).and_return(90)
77
+ mock_mini_magick(name: 'library', title: 'scov library',
78
+ color: '#4dc71f', coverage: '90',
79
+ stack: stack, convert:
80
+ mock_mini_magick(name: 'total', title: 'scov total',
81
+ color: 'red', coverage: '89',
82
+ stack: stack))
83
+ result = mock_result(89, 'library': mock_result_group(90))
84
+ expect(subject.format(result)).to be_truthy
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ require 'byebug'
5
+
6
+ SimpleCov.start do
7
+ module SimpleCovSmallBadge
8
+ class Formatter
9
+ end
10
+ end
11
+
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
+ [
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ SimpleCovSmallBadge::Formatter
16
+ ]
17
+ )
18
+ end
19
+
20
+ SimpleCov.minimum_coverage 100
21
+
22
+ require 'simplecov_small_badge'
23
+ require 'rubygems'
24
+ require 'bundler/setup'
25
+
26
+ Dir[File.join('./spec/support/*.rb')].each { |f| require f }
27
+
28
+ SimpleCovSmallBadge.configure do |config|
29
+ # config.rounded_border = false
30
+ end
31
+
32
+ RSpec.configure do |config|
33
+ # some (optional) config here
34
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TestSimpleCovSmallBadge
4
+ module Mocks
5
+ # rubocop:disable Metrics/LineLength
6
+ def pango_text_match(title = 'scov total', color = 'green', cov = '100%')
7
+ %(<span foreground="white"
8
+ background="#595959" size="16000" font="Helvetica" > #{title} </span><span foreground="white"
9
+ background="#{color}" size="16000" font="Helvetica-Narrow-Bold" > #{cov} </span>)
10
+ end
11
+ # rubocop:enable Metrics/LineLength
12
+
13
+ # rubocop:disable Metrics/LineLength, Metrics/AbcSize
14
+ def mock_mini_magick_stack(stack = instance_double('Stack'))
15
+ allow(stack).to receive_message_chain('clone.+')
16
+ allow(stack).to receive(:alpha).with('extract')
17
+ allow(stack).to receive(:draw).with('fill black polygon 0,0 0,3 3,0 fill white circle 3,3 3,0')
18
+ allow(stack).to receive(:flip)
19
+ allow(stack).to receive(:flop)
20
+ allow(stack).to receive(:compose).with('Multiply')
21
+ allow(stack).to receive(:composite)
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)
43
+ end
44
+ allow(convert).to receive(:<<)
45
+ .with("#{SimpleCov.coverage_path}/coverage_badge_#{keys[:name]}.png")
46
+ convert
47
+ end
48
+ # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
49
+
50
+ def mock_result(total_cov, groups_hash = {})
51
+ result_double = instance_double('Result')
52
+ allow(result_double)
53
+ .to receive_message_chain('source_files.covered_percent')
54
+ .and_return(total_cov)
55
+ allow(result_double).to receive('groups').and_return(groups_hash)
56
+ result_double
57
+ end
58
+
59
+ def mock_result_group(cov, strength = 1)
60
+ group_double = instance_double('Group')
61
+ allow(group_double)
62
+ .to receive('covered_percent')
63
+ .and_return(cov)
64
+ allow(group_double)
65
+ .to receive('covered_strength')
66
+ .and_return(strength)
67
+ group_double
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-small-badge
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Marc Grimme
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-11 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: repo-small-badge
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Small Badge generator for SimpleCov coverage tool for ruby
98
+ email:
99
+ - marc.grimme at gmail dot com
100
+ executables:
101
+ - console
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".document"
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".ruby-gemset"
110
+ - ".ruby-version"
111
+ - ".travis.yml"
112
+ - Gemfile
113
+ - MIT-LICENSE
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - lib/simplecov_small_badge.rb
118
+ - lib/simplecov_small_badge/configuration.rb
119
+ - lib/simplecov_small_badge/formatter.rb
120
+ - lib/simplecov_small_badge/version.rb
121
+ - script/travis.sh
122
+ - simplecov-small-badge.gemspec
123
+ - spec/simplecov_small_badge_configuration_spec.rb
124
+ - spec/simplecov_small_badge_formatter_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/support/mocks.rb
127
+ homepage: https://github.com/marcgrimme/simplecov-small-badge
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project: simplecov-small-badge
147
+ rubygems_version: 2.7.6
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Small Badge generator for SimpleCov coverage tool for ruby
151
+ test_files: []