simplecov-formatter-badge 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f61ff2e514b6e327a6904484839fe4de9363a17
4
+ data.tar.gz: 11c3f9c99532ac5a8ce4f79389fef461bca40e15
5
+ SHA512:
6
+ metadata.gz: 983061ac74bb913031ccbc36e252fb0624f5b7bfd29f9de4e14aa90c7099b2f4e2fda09b53a631af4cb3186e4163890b3ab1517a99930dbfd463cf8f178fe37c
7
+ data.tar.gz: f7ba02b5414463d3124cb297c4ffaeca6bc4424cb6f9a8483a8df10f4eed03f78cae53f5b9ce7f2dab5b928892f972f74ca46bf466b5635cf114cfe452bbe100
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in simplecov-formatter-badge.gemspec
6
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simplecov-formatter-badge (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.11.3)
10
+ rake (10.5.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.16)
17
+ minitest (~> 5.0)
18
+ rake (~> 10.0)
19
+ simplecov-formatter-badge!
20
+
21
+ BUNDLED WITH
22
+ 1.16.0
@@ -0,0 +1,29 @@
1
+ # Simplecov Badge Formatter
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'simplecov-formatter-badge', require: false
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require 'simplecov-formatter-badge'
19
+ SimpleCov.formatter =
20
+ SimpleCov::Formatter::MultiFormatter.new \
21
+ [SimpleCov::Formatter::HTMLFormatter,
22
+ SimpleCov::Formatter::BadgeFormatter]
23
+ ```
24
+
25
+ then use it from your README
26
+
27
+ ```md
28
+ [![coverage](https://path.to.report/coverage.svg)](https://path.to.report/)
29
+ ```
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "simplecov/formatter/badge"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,49 @@
1
+ module SimpleCov
2
+ module Formatter
3
+ class BadgeFormatter
4
+ RESULT_FILE_NAME = 'coverage.svg'
5
+
6
+ def format(result)
7
+ persent = result.covered_percent.to_i
8
+ color = color_by(persent)
9
+ File.open(result_file_path, "w" ) do |file|
10
+ file.write <<~XML
11
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="94" height="20">
12
+ <linearGradient id="b" x2="0" y2="100%">
13
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
14
+ <stop offset="1" stop-opacity=".1"/>
15
+ </linearGradient>
16
+ <clipPath id="a">
17
+ <rect width="94" height="20" rx="3" fill="#fff"/>
18
+ </clipPath>
19
+ <g clip-path="url(#a)">
20
+ <path fill="#555" d="M0 0h59v20H0z"/>
21
+ <path fill="#{color}" d="M59 0h35v20H59z"/>
22
+ <path fill="url(#b)" d="M0 0h94v20H0z"/>
23
+ </g>
24
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
25
+ <text x="305" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="490">coverage</text>
26
+ <text x="305" y="140" transform="scale(.1)" textLength="490">coverage</text>
27
+ <text x="755" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">#{persent}%</text>
28
+ <text x="755" y="140" transform="scale(.1)" textLength="250">#{persent}%</text></g>
29
+ </svg>
30
+ XML
31
+ end
32
+ end
33
+
34
+ def result_file_path
35
+ File.join(SimpleCov.coverage_path, RESULT_FILE_NAME)
36
+ end
37
+
38
+ def color_by(persent)
39
+ if persent > 90
40
+ '#4c1'
41
+ elsif persent > 80
42
+ '#dfb317'
43
+ else
44
+ '#e05d44'
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'simplecov-formatter-badge'
6
+ spec.version = '0.1.0'
7
+ spec.authors = ['Shim Won']
8
+ spec.email = ['marocchino@gmail.com']
9
+
10
+ spec.summary = 'badge formatter for simplecov'
11
+ spec.description = ''
12
+ spec.homepage = 'https://github.com/marocchino/simplecov-formatter-badge'
13
+
14
+ if spec.respond_to?(:metadata)
15
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
16
+ else
17
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
18
+ 'public gem pushes.'
19
+ end
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.16'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'minitest', '~> 5.0'
31
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplecov-formatter-badge
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shim Won
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: ''
56
+ email:
57
+ - marocchino@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/simplecov-formatter-badge.rb
71
+ - simplecov-formatter-badge.gemspec
72
+ homepage: https://github.com/marocchino/simplecov-formatter-badge
73
+ licenses: []
74
+ metadata:
75
+ allowed_push_host: https://rubygems.org
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.6.13
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: badge formatter for simplecov
96
+ test_files: []