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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4ae7844bac6556edaf7ad55d133aa73c7965acb9b43f57a083217688dfca11d
4
- data.tar.gz: b61e4964ffd48ed08bcbbd538dc2e0731000125265b89e0bfbddba44ce72dc5c
3
+ metadata.gz: 5ae8a9b3c00f951fd5b5408a66873395c9479d6b819bd933594a1530fb7e4a8d
4
+ data.tar.gz: '0601491388641f48d9a5d22ff53798937a860335667f0b4597255137b842e71d'
5
5
  SHA512:
6
- metadata.gz: e62cee88e3a0b2282db85c42b7873ac3ed882909dd926de9d1f51749c7e8aaca71400c2ffcca5838ae8eee6eae9cc5a8d153b896af4771cd543f85fa626d4fe3
7
- data.tar.gz: c5daca06b0d90819da609c8c8f4d8429e847657984c5f1864402ff9a267ed86ae477fa4b9062b2e2b3f44e991bc5000488ef6c1b3613616ceaa09b04cde39bb4
6
+ metadata.gz: d965bee53294e994e5ae5b6b5a9a07d1e494e296d5c552b8813c35237fb348fb32b763ed23cef22185f825e673855a30385df78f35d5d61527fcaf3843ee2a96
7
+ data.tar.gz: 3f4dacbcf670d4bf663b7ba3b0924a59282f6a17a7e377ba780a87599fbba0800f245be9281578d782144fa0fcada8fe49fa74ca41e561b35d19444bc39ecf1d
@@ -36,7 +36,7 @@ jobs:
36
36
  name: Store coverage report
37
37
  command: |
38
38
  mv coverage/coverage.json /tmp/coverage/
39
- mv coverage/shield-coverage.json /tmp/coverage/
39
+ mv coverage/badge.svg /tmp/coverage/
40
40
  - persist_to_workspace:
41
41
  root: /tmp/coverage
42
42
  paths: .
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://img.shields.io/endpoint?url=https://edgepetrol.github.io/coverage/simplecov-shield-json/master/shield-coverage.json)
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 JSON can be found in coverage/shield-coverage.json
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
- json = shield_json(result)
13
+ shield_url = shield_json(result)
13
14
 
14
15
  File.open(output_filepath, 'w+') do |file|
15
- file.puts json
16
+ file.puts URI.open(shield_url).read
16
17
  end
17
18
 
18
19
  puts output_message(result)
19
20
 
20
- json
21
+ shield_url
21
22
  end
22
23
 
23
24
  private
24
25
 
25
26
  def output_filename
26
- 'shield-coverage.json'
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
@@ -3,7 +3,7 @@
3
3
  module SimpleCov
4
4
  module Formatter
5
5
  class ShieldJSONFormatter
6
- VERSION = '0.0.6'
6
+ VERSION = '1.0.1'
7
7
  end
8
8
  end
9
9
  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: 0.0.6
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-19 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json