rubycritic-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 +7 -0
- data/.document +5 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/MIT-LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +22 -0
- data/bin/console +21 -0
- data/lib/rubycritic_small_badge/configuration.rb +54 -0
- data/lib/rubycritic_small_badge/report.rb +66 -0
- data/lib/rubycritic_small_badge/version.rb +5 -0
- data/lib/rubycritic_small_badge.rb +19 -0
- data/rubycritic-small-badge.gemspec +31 -0
- data/script/travis.sh +14 -0
- data/spec/rubycritic_small_badge_configuration_spec.rb +15 -0
- data/spec/rubycritic_small_badge_report_spec.rb +37 -0
- data/spec/rubycritic_small_badge_spec.rb +26 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/mocks.rb +46 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ddbbc6feafc63c4d9f92247d8057ceb7709e256d944415be71f7a1ad65fdc110
|
4
|
+
data.tar.gz: 39aed2496e24a48a2ddbe05570b9f3b8a8d4ea28f748602c8c2f269bdd0eae07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ad14813e2b43e636445c2c3d36276cf23626966afe41d4e90a5b7c8bb85abb92b019e952ce8af0a2991d88013ef5c85a7379d4813989f93519b383f714b27e3
|
7
|
+
data.tar.gz: 81131ba2a2d75e6d02d026bdc79b8f78a36195445cee4591f0e9a1cfd77bc97486a55b990b5ffb5bc294328a7f201b1856b77589990e21dce13fde92eb008e80
|
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rubycritic-small-badge
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
branches:
|
3
|
+
only:
|
4
|
+
- master
|
5
|
+
rvm:
|
6
|
+
- 2.5.3
|
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/CHANGELOG.md
ADDED
data/Gemfile
ADDED
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,70 @@
|
|
1
|
+
# RubyCriticSmallBadge
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/rubycritic-small-badge)
|
4
|
+
[](https://secure.travis-ci.org/MarcGrimme/rubycritic-small-badge)
|
5
|
+
[](https://depfu.com/github/MarcGrimme/rubycritic-small-badge?project_id=6900)
|
6
|
+
[](https://marcgrimme.github.io/rubycritic-small-badge/coverage/index.html)
|
7
|
+
[](https://marcgrimme.github.io/rubycritic-small-badge/tmp/rubycritic/overview.html)
|
8
|
+
|
9
|
+
*RubyCriticCovBadge* is a gem that can be added to the `Gemfile` and will produce a file called `rubycritic_badge_score.svg` in the `badges` directory.
|
10
|
+
It could be looking as follows dependent on how it is configured.
|
11
|
+
|
12
|
+
...
|
13
|
+
|
14
|
+
The idea is to created a badge for [RubyCritic](https://github.com/whitesmith/rubycritic) to create a persistable image that shows the score as a badge.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
The badge creation is dependent on the [RubySmallBadge gem](https://github.com/marcgrimme/ruby-small-badge).
|
19
|
+
It can be installed in your Ruby library or rails app as part of the `Gemfile` as follows.
|
20
|
+
|
21
|
+
```
|
22
|
+
# In your gemfile
|
23
|
+
gem 'rubycritic-small-badge', :require => false
|
24
|
+
```
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Whereever you are integrating `Rubycritic` you can have to integrate as a Raketask. The default integration could looks as follows:
|
31
|
+
|
32
|
+
```Rakefile
|
33
|
+
require 'rubycritic_small_badge'
|
34
|
+
require 'rubycritic/rake_task'
|
35
|
+
RubyCriticSmallBadge.configure do |config|
|
36
|
+
config.minimum_score = 90
|
37
|
+
end
|
38
|
+
RubyCritic::RakeTask.new do |task|
|
39
|
+
task.options = %(--formatter RubyCriticSmallBadge::Report
|
40
|
+
--minimum-score #{RubyCriticSmallBadge.config.minimum_score})
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Integration into Travis-CI via github-pages
|
45
|
+
|
46
|
+
This process is split into two steps.
|
47
|
+
|
48
|
+
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/)
|
49
|
+
|
50
|
+
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)
|
51
|
+
|
52
|
+
3. Integrate your badge into the README.md as follows ````
|
53
|
+
|
54
|
+
## Configuration Options
|
55
|
+
|
56
|
+
The behaviour of `RubyCriticmallBadge` can be influenced by configuration options as defined in the [configuration class](lib/rubycritic_small_badge/configuration.rb).
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/marcgrimme/rubycritic-small-badge/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
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
|
+
require 'rubycritic_small_badge'
|
10
|
+
require 'rubycritic/rake_task'
|
11
|
+
RubyCriticSmallBadge.configure do |config|
|
12
|
+
config.minimum_score = ENV.fetch('RUBYCRITICLIMIT', 90.0)
|
13
|
+
end
|
14
|
+
RubyCritic::RakeTask.new do |task|
|
15
|
+
task.options = %(--formatter RubyCriticSmallBadge::Report
|
16
|
+
--minimum-score #{RubyCriticSmallBadge.config.minimum_score}
|
17
|
+
--format html --format console)
|
18
|
+
task.paths = FileList['lib/**/*.rb']
|
19
|
+
end
|
20
|
+
|
21
|
+
# If you want to make this the default task
|
22
|
+
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,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyCriticSmallBadge
|
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
|
+
with_analysers: false,
|
12
|
+
background: '#fff',
|
13
|
+
title_prefix: 'rubycritic',
|
14
|
+
title_background: '#555',
|
15
|
+
title_font: 'Verdana,sans-serif',
|
16
|
+
title_font_color: '#fff',
|
17
|
+
score_background_bad: '#ff0000',
|
18
|
+
score_background_unknown: '#cccc00',
|
19
|
+
score_background_good: '#4dc71f',
|
20
|
+
score_font: 'Verdana,sans-serif',
|
21
|
+
score_font_color: '#fff',
|
22
|
+
font: 'Verdana,sans-serif',
|
23
|
+
font_size: 11,
|
24
|
+
badge_height: 20,
|
25
|
+
badge_width: 200,
|
26
|
+
filename_prefix: 'rubycritic_badge',
|
27
|
+
output_path: 'badges',
|
28
|
+
rounded_border: true,
|
29
|
+
rounded_edge_radius: 3,
|
30
|
+
minimum_score: nil
|
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
|
+
RubyCriticSmallBadge::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,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'repo_small_badge/image'
|
4
|
+
require 'rubycritic_small_badge/configuration'
|
5
|
+
|
6
|
+
module RubyCriticSmallBadge
|
7
|
+
# Basic Badge Formater Class that creates the badges.
|
8
|
+
class Report
|
9
|
+
def initialize(analysed_modules)
|
10
|
+
@config = RubyCriticSmallBadge.config
|
11
|
+
@analysed_modules = analysed_modules
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_report
|
15
|
+
mk_output_dir!
|
16
|
+
score = @analysed_modules.score
|
17
|
+
@image = RepoSmallBadge::Image.new(map_image_config(state(score)))
|
18
|
+
badge('score', 'score', score)
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def max_score
|
25
|
+
100.0
|
26
|
+
end
|
27
|
+
|
28
|
+
def mk_output_dir!
|
29
|
+
FileUtils.mkdir_p(@config.output_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def badge(name, title, score)
|
33
|
+
value_txt = score_text(score)
|
34
|
+
@image.config_merge(map_image_config(state(score)))
|
35
|
+
@image.badge(name, title, value_txt)
|
36
|
+
end
|
37
|
+
|
38
|
+
def score_text(score)
|
39
|
+
"#{score}/#{max_score}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def state(value)
|
43
|
+
if @config.minimum_score&.positive?
|
44
|
+
if value >= @config.minimum_score
|
45
|
+
'good'
|
46
|
+
else
|
47
|
+
'bad'
|
48
|
+
end
|
49
|
+
else
|
50
|
+
'unknown'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def map_image_config(state)
|
55
|
+
hash = {}
|
56
|
+
@config.to_hash.map do |key, value|
|
57
|
+
key = key
|
58
|
+
.to_s.sub(/^score_background_#{state}/, 'value_background')
|
59
|
+
.to_sym
|
60
|
+
key = key.to_s.sub(/^score_/, 'value_').to_sym
|
61
|
+
hash[key] = value
|
62
|
+
end
|
63
|
+
hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubycritic_small_badge/configuration'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module RubyCriticSmallBadge
|
7
|
+
@configuration = Configuration.new
|
8
|
+
def self.configure
|
9
|
+
yield config
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.config
|
13
|
+
@configuration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
18
|
+
require 'rubycritic_small_badge/version'
|
19
|
+
require 'rubycritic_small_badge/report'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
require 'rubycritic_small_badge/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'rubycritic-small-badge'
|
8
|
+
s.version = RubyCriticSmallBadge::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/rubycritic-small-badge'
|
14
|
+
s.summary = %(Small Badge generator for RubyCritic analysis tool for ruby)
|
15
|
+
s.description = %(Small Badge generator for RubyCritic coverage tool for ruby)
|
16
|
+
|
17
|
+
s.rubyforge_project = 'rubycritic-small-badge'
|
18
|
+
|
19
|
+
s.add_dependency 'repo-small-badge', '~> 0.2.2'
|
20
|
+
s.add_development_dependency 'rake', '~> 12'
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.8'
|
22
|
+
s.add_development_dependency 'rubocop', '~> 0.65'
|
23
|
+
s.add_development_dependency 'simplecov', '~> 0.16'
|
24
|
+
s.add_development_dependency 'simplecov-small-badge', '~> 0.2'
|
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
|
data/script/travis.sh
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
set -e
|
3
|
+
RUBYCRITICLIMIT=${RUBYCRITICLIMIT:-"90.0"}
|
4
|
+
QUICK=${QUICK:-}
|
5
|
+
|
6
|
+
bundle exec rspec
|
7
|
+
bundle exec rubocop
|
8
|
+
if [ -z "$QUICK" ]; then
|
9
|
+
gem install bundler-audit && bundle-audit update && bundle-audit check
|
10
|
+
bundle exec rake rubycritic
|
11
|
+
echo "Pushing badges upstream"
|
12
|
+
[ -d badges ] || mkdir badges
|
13
|
+
cp coverage/coverage_badge* badges/ 2>/dev/null || true
|
14
|
+
fi
|
@@ -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,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyCriticSmallBadge::Report do
|
6
|
+
include TestRubyCriticSmallBadge::Mocks
|
7
|
+
|
8
|
+
describe '#generate_report' do
|
9
|
+
context 'bad result' do
|
10
|
+
subject { described_class.new(mock_analysed_modules(50.0)) }
|
11
|
+
it do
|
12
|
+
allow(RubyCriticSmallBadge.config).to receive(:minimum_score)
|
13
|
+
.and_return(90.0)
|
14
|
+
mock_repo_badge_image(score: '50.0/100.0', state: 'bad')
|
15
|
+
expect(subject.generate_report).to be_truthy
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'good result' do
|
20
|
+
subject { described_class.new(mock_analysed_modules(100.0)) }
|
21
|
+
it do
|
22
|
+
allow(RubyCriticSmallBadge.config).to receive(:minimum_score)
|
23
|
+
.and_return(90.0)
|
24
|
+
mock_repo_badge_image(score: '100.0/100.0')
|
25
|
+
expect(subject.generate_report).to be_truthy
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'unknown result' do
|
30
|
+
subject { described_class.new(mock_analysed_modules(100.0)) }
|
31
|
+
it do
|
32
|
+
mock_repo_badge_image(score: '100.0/100.0', state: 'unknown')
|
33
|
+
expect(subject.generate_report).to be_truthy
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyCriticSmallBadge do
|
6
|
+
describe '#configure' do
|
7
|
+
context 'set config' do
|
8
|
+
it do
|
9
|
+
described_class.configure do |config|
|
10
|
+
config.score_font = 'TestFont'
|
11
|
+
end
|
12
|
+
expect(described_class.config.score_font).to eq 'TestFont'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'wrong config' do
|
17
|
+
it do
|
18
|
+
expect do
|
19
|
+
described_class.configure do |config|
|
20
|
+
config.wrong_value = 'test12'
|
21
|
+
end
|
22
|
+
end.to raise_error(NoMethodError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'byebug'
|
5
|
+
require 'simplecov_small_badge'
|
6
|
+
|
7
|
+
SimpleCov.start do
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
9
|
+
[
|
10
|
+
SimpleCov::Formatter::HTMLFormatter,
|
11
|
+
SimpleCovSmallBadge::Formatter
|
12
|
+
]
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
SimpleCov.minimum_coverage 100
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
require 'bundler/setup'
|
20
|
+
require 'rubycritic_small_badge'
|
21
|
+
|
22
|
+
Dir[File.join('./spec/support/*.rb')].each { |f| require f }
|
23
|
+
|
24
|
+
SimpleCovSmallBadge.configure do |config|
|
25
|
+
# config.rounded_border = false
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
# some (optional) config here
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyCritic
|
4
|
+
class Rating
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module TestRubyCriticSmallBadge
|
9
|
+
module Mocks
|
10
|
+
# rubocop:disable Metrics/ParameterLists, Metrics/AbcSize
|
11
|
+
def mock_repo_badge_image(score: 100, name: 'score',
|
12
|
+
title: 'score',
|
13
|
+
state: 'good',
|
14
|
+
config: {},
|
15
|
+
mock: instance_double('Image'))
|
16
|
+
config = map_config_options(config, state)
|
17
|
+
allow(RepoSmallBadge::Image).to receive(:new)
|
18
|
+
.with(config).and_return(mock)
|
19
|
+
allow(mock).to receive(:config_merge).with(config).and_return(config)
|
20
|
+
allow(mock).to receive(:badge).with(name, title, score)
|
21
|
+
mock
|
22
|
+
end
|
23
|
+
# rubocop:enable Metrics/ParameterLists, Metrics/AbcSize
|
24
|
+
|
25
|
+
def map_config_options(config_hash, state)
|
26
|
+
hash = {}
|
27
|
+
RubyCriticSmallBadge::Configuration.options.merge(config_hash)
|
28
|
+
.map do |key, value|
|
29
|
+
key = key.to_s
|
30
|
+
.sub(/^score_background_#{state}/, 'value_background')
|
31
|
+
.to_sym
|
32
|
+
key = key.to_s.sub(/^score_/, 'value_').to_sym
|
33
|
+
hash[key] = value
|
34
|
+
end
|
35
|
+
hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def mock_analysed_modules(score = 100.0)
|
39
|
+
analysed_mod_double = instance_double('RubyCritic::AnalysedModules')
|
40
|
+
allow(analysed_mod_double)
|
41
|
+
.to receive('score')
|
42
|
+
.and_return(score)
|
43
|
+
analysed_mod_double
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubycritic-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-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: repo-small-badge
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.65'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.65'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.16'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.16'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-small-badge
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
97
|
+
description: Small Badge generator for RubyCritic 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
|
+
- CHANGELOG.md
|
113
|
+
- Gemfile
|
114
|
+
- MIT-LICENSE
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- lib/rubycritic_small_badge.rb
|
119
|
+
- lib/rubycritic_small_badge/configuration.rb
|
120
|
+
- lib/rubycritic_small_badge/report.rb
|
121
|
+
- lib/rubycritic_small_badge/version.rb
|
122
|
+
- rubycritic-small-badge.gemspec
|
123
|
+
- script/travis.sh
|
124
|
+
- spec/rubycritic_small_badge_configuration_spec.rb
|
125
|
+
- spec/rubycritic_small_badge_report_spec.rb
|
126
|
+
- spec/rubycritic_small_badge_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/support/mocks.rb
|
129
|
+
homepage: https://github.com/marcgrimme/rubycritic-small-badge
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project: rubycritic-small-badge
|
149
|
+
rubygems_version: 2.7.7
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Small Badge generator for RubyCritic analysis tool for ruby
|
153
|
+
test_files: []
|