Added [codetally] (#1069)
This commit is contained in:
committed by
Paul Melnikow
parent
13502b3a22
commit
20ab540fb2
26
server.js
26
server.js
@@ -1150,6 +1150,32 @@ cache(function(data, match, sendBadge, request) {
|
||||
});
|
||||
}));
|
||||
|
||||
// Codetally integration.
|
||||
camp.route(/^\/codetally\/(.*)\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
cache(function(data, match, sendBadge, request) {
|
||||
var owner = match[1]; // eg, triggerman722.
|
||||
var repo = match[2]; // eg, colorstrap
|
||||
var format = match[3];
|
||||
var apiUrl = 'http://www.codetally.com/formattedshield/' + owner + '/' + repo;
|
||||
var badgeData = getBadgeData('codetally', data);
|
||||
request(apiUrl, function dealWithData(err, res, buffer) {
|
||||
if (err != null) {
|
||||
badgeData.text[1] = 'inaccessible';
|
||||
sendBadge(format, badgeData);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var data = JSON.parse(buffer);
|
||||
badgeData.text[1] = " " + data.currency_sign + data.amount + " " + data.multiplier;
|
||||
badgeData.colorscheme = null;
|
||||
badgeData.colorB = '#2E8B57';
|
||||
sendBadge(format, badgeData);
|
||||
} catch(e) {
|
||||
badgeData.text[1] = 'invalid';
|
||||
sendBadge(format, badgeData);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
// Bountysource integration.
|
||||
|
||||
30
service-tests/codetally.js
Normal file
30
service-tests/codetally.js
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const Joi = require('joi');
|
||||
const ServiceTester = require('./runner/service-tester');
|
||||
|
||||
const t = new ServiceTester({ id : 'codetally', title: 'Codetally' });
|
||||
module.exports = t;
|
||||
|
||||
// This test will extract the currency value from the
|
||||
// string value response from the server.
|
||||
// \b = Asset position at word boundary
|
||||
// \d+ = match a digit [0-9]
|
||||
// credit for this regex goes to:
|
||||
// https://stackoverflow.com/questions/38074000/how-to-get-float-value-from-string-using-regex
|
||||
|
||||
t.create('Codetally')
|
||||
.get('/triggerman722/colorstrap.json')
|
||||
.expectJSONTypes(Joi.object().keys({
|
||||
name: Joi.equal('codetally'),
|
||||
value: Joi.string().regex(/\b\d+(?:.\d+)?/)
|
||||
}));
|
||||
|
||||
|
||||
t.create('Empty')
|
||||
.get('/triggerman722/colorstrap.json')
|
||||
.intercept(nock => nock('http://www.codetally.com')
|
||||
.get('/formattedshield/triggerman722/colorstrap')
|
||||
.reply(200, { currency_sign:'$', amount:'0.00', multiplier:'', currency_abbreviation:'CAD' })
|
||||
)
|
||||
.expectJSON({ name: 'codetally', value: ' $0.00 '});
|
||||
4
try.html
4
try.html
@@ -702,6 +702,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
||||
<td><img src='/codeclimate/issues/github/me-and/mdf.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/codeclimate/issues/github/me-and/mdf.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Codetally:</th>
|
||||
<td><img src='/codetally/triggerman722/colorstrap.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/codetally/triggerman722/colorstrap.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> bitHound: </th>
|
||||
<td><img src='/bithound/code/github/rexxars/sse-channel.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/bithound/code/github/rexxars/sse-channel.svg</code></td>
|
||||
|
||||
Reference in New Issue
Block a user