simplecov-shield-json 0.0.6 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/README.md +2 -13
- data/lib/simplecov-shield-json.rb +6 -11
- data/lib/simplecov-shield-json/version.rb +1 -1
- data/spec/lib/simplecov_shield_json_spec.rb +4 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ae8a9b3c00f951fd5b5408a66873395c9479d6b819bd933594a1530fb7e4a8d
|
4
|
+
data.tar.gz: '0601491388641f48d9a5d22ff53798937a860335667f0b4597255137b842e71d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d965bee53294e994e5ae5b6b5a9a07d1e494e296d5c552b8813c35237fb348fb32b763ed23cef22185f825e673855a30385df78f35d5d61527fcaf3843ee2a96
|
7
|
+
data.tar.gz: 3f4dacbcf670d4bf663b7ba3b0924a59282f6a17a7e377ba780a87599fbba0800f245be9281578d782144fa0fcada8fe49fa74ca41e561b35d19444bc39ecf1d
|
data/.circleci/config.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![EdgePetrol](https://circleci.com/gh/EdgePetrol/simplecov-shield-json.svg?style=shield)](https://app.circleci.com/pipelines/github/EdgePetrol/simplecov-shield-json)
|
2
|
-
![EdgePetrol](https://
|
2
|
+
![EdgePetrol](https://github.com/EdgePetrol/coverage/blob/master/simplecov-shield-json/master/badge.svg)
|
3
3
|
|
4
4
|
# simplecov-shield-json
|
5
5
|
|
@@ -18,15 +18,4 @@ Shield JSON formatter for the ruby 1.9+ code coverage gem SimpleCov
|
|
18
18
|
|
19
19
|
## Result
|
20
20
|
|
21
|
-
Generated
|
22
|
-
|
23
|
-
The format you can expect is:
|
24
|
-
```
|
25
|
-
{
|
26
|
-
"schemaVersion": 1,
|
27
|
-
"label": "Coverage",
|
28
|
-
"message": "99.9%",
|
29
|
-
"color": "green",
|
30
|
-
"cacheSeconds": 1800
|
31
|
-
}
|
32
|
-
```
|
21
|
+
Generated badge svg can be found in coverage/badge.svg
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
4
|
require 'json'
|
5
|
+
require 'open-uri'
|
5
6
|
require_relative 'simplecov-shield-json/version'
|
6
7
|
|
7
8
|
module SimpleCov
|
@@ -9,21 +10,21 @@ module SimpleCov
|
|
9
10
|
# shield json generator
|
10
11
|
class ShieldJSONFormatter
|
11
12
|
def format(result)
|
12
|
-
|
13
|
+
shield_url = shield_json(result)
|
13
14
|
|
14
15
|
File.open(output_filepath, 'w+') do |file|
|
15
|
-
file.puts
|
16
|
+
file.puts URI.open(shield_url).read
|
16
17
|
end
|
17
18
|
|
18
19
|
puts output_message(result)
|
19
20
|
|
20
|
-
|
21
|
+
shield_url
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def output_filename
|
26
|
-
'
|
27
|
+
'badge.svg'
|
27
28
|
end
|
28
29
|
|
29
30
|
def output_filepath
|
@@ -51,13 +52,7 @@ module SimpleCov
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def shield_json(result)
|
54
|
-
{
|
55
|
-
schemaVersion: 1,
|
56
|
-
label: 'Coverage',
|
57
|
-
message: "#{result.covered_percent.round(2)}%",
|
58
|
-
color: color(result.covered_percent),
|
59
|
-
cacheSeconds: 1800
|
60
|
-
}.to_json
|
55
|
+
"https://img.shields.io/badge/Coverage-#{result.covered_percent.round(2)}#{CGI.escape('%')}-#{color(result.covered_percent)}.svg"
|
61
56
|
end
|
62
57
|
end
|
63
58
|
end
|
@@ -5,6 +5,9 @@ require File.expand_path('../spec_helper', __dir__)
|
|
5
5
|
|
6
6
|
# rubocop:disable Metrics/BlockLength
|
7
7
|
describe SimpleCov::Formatter::ShieldJSONFormatter do
|
8
|
+
before do
|
9
|
+
allow(URI).to receive_message_chain(:open, :read).and_return('<svg></svg>')
|
10
|
+
end
|
8
11
|
shared_examples 'percentage color' do |percentage, color|
|
9
12
|
context 'generating report' do
|
10
13
|
before do
|
@@ -13,13 +16,7 @@ describe SimpleCov::Formatter::ShieldJSONFormatter do
|
|
13
16
|
|
14
17
|
it "with #{percentage} should return #{color}" do
|
15
18
|
expect(described_class.new.format(simplecov_result)).to eq(
|
16
|
-
{
|
17
|
-
'schemaVersion': 1,
|
18
|
-
'label': 'Coverage',
|
19
|
-
'message': "#{percentage}%",
|
20
|
-
'color': color,
|
21
|
-
'cacheSeconds': 1800
|
22
|
-
}.to_json
|
19
|
+
"https://img.shields.io/badge/Coverage-#{percentage}#{CGI.escape('%')}-#{color}.svg"
|
23
20
|
)
|
24
21
|
end
|
25
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov-shield-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Pereira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|