Coverage badge.

This commit is contained in:
Thaddee Tyl 2014-01-19 12:19:35 +01:00
parent 383f746702
commit db80e6c650
3 changed files with 26 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# GitHub badges in SVG format
[![npm version](http://b.adge.me/npm/v/gh-badges.svg)](https://npmjs.org/package/gh-badges)
![coverage](https://rawgithub.com/badges/gh-badges/master/coverage.svg)
Make your own [badges][] (like this one above)!
Make your own badges [here][badges]!
[badges]: <http://b.adge.me>

1
coverage.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="110" height="18"><linearGradient id="a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-opacity=".3"/><stop offset="1" stop-opacity=".5"/></linearGradient><rect rx="4" width="110" height="18" fill="#555"/><rect rx="4" x="63" width="47" height="18" fill="#e05d44"/><path fill="#e05d44" d="M63 0h4v18h-4z"/><rect rx="4" width="110" height="18" fill="url(#a)"/><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="32.5" y="13" fill="#010101" fill-opacity=".3">coverage</text><text x="32.5" y="12">coverage</text><text x="85.5" y="13" fill="#010101" fill-opacity=".3">38.3%</text><text x="85.5" y="12">38.3%</text></g></svg>

After

Width:  |  Height:  |  Size: 827 B

23
test.js
View File

@ -104,4 +104,27 @@ describe('the ass wrap-up', function() {
done();
});
});
it('should write the coverage image', function(done) {
ass.report('json', function(err, r) {
if (!!err) { return done(err); }
var badge = require('./badge.js');
var score = +r.percent;
var badgeData = {text:['coverage', score + '%']};
if (score < 70) {
badgeData.colorscheme = 'red';
} else if (score < 80) {
badgeData.colorscheme = 'yellow';
} else if (score < 90) {
badgeData.colorscheme = 'yellowgreen';
} else if (score < 100) {
badgeData.colorscheme = 'green';
} else {
badgeData.colorscheme = 'brightgreen';
}
badge(badgeData, function writeBadge(svg) {
fs.writeFileSync('./coverage.svg', svg);
done();
});
});
});
});