Merge remote-tracking branch 'jfitzpatrick99/master'

This commit is contained in:
Thaddee Tyl 2015-06-10 22:49:16 +02:00
commit e6bafd0b4a
2 changed files with 53 additions and 0 deletions

View File

@ -721,6 +721,51 @@ cache(function(data, match, sendBadge, request) {
});
}));
// Coverity Code Advisor On Demand integration
camp.route(/^\/coverity\/ondemand\/(.+)\/(.+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var badgeType = match[1]; // One of the strings "streams" or "jobs"
var badgeTypeId = match[2]; // streamId or jobId
var format = match[3];
var badgeData = getBadgeData('coverity', data);
if ((badgeType == 'jobs' && badgeTypeId == 'JOB') ||
(badgeType == 'streams' && badgeTypeId == 'STREAM')) {
// Request is for a static demo badge
badgeData.text[1] = 'clean';
badgeData.colorscheme = 'green'
sendBadge(format, badgeData);
return;
} else {
//
// Request is for a real badge; send request to Coverity On Demand API
// server to get the badge
//
// Example URLs for requests sent to Coverity On Demand are:
//
// https://api.ondemand.coverity.com/streams/44b25sjc9l3ntc2ngfi29tngro/badge
// https://api.ondemand.coverity.com/jobs/p4tmm8031t4i971r0im4s7lckk/badge
//
var url = 'https://api.ondemand.coverity.com/' +
badgeType + '/' + badgeTypeId + '/badge';
request(url, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
badgeData = JSON.parse(buffer);
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}
}));
// Gratipay integration.
camp.route(/^\/(gittip|gratipay)\/(.*)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {

View File

@ -184,6 +184,14 @@ Pixel-perfect   Retina-ready   Fast   Consistent   Hackable
<td><img src='/coverity/scan/3997.svg' alt=''/></td>
<td><code>https://img.shields.io/coverity/scan/3997.svg</code></td>
</tr>
<tr><th> Coverity Code Advisor On Demand Stream Badge: </th>
<td><img src='/coverity/ondemand/streams/STREAM.svg' alt=''/></td>
<td><code>https://img.shields.io/coverity/ondemand/streams/STREAM.svg</code></td>
</tr>
<tr><th> Coverity Code Advisor On Demand Job Badge: </th>
<td><img src='/coverity/ondemand/jobs/JOB.svg' alt=''/></td>
<td><code>https://img.shields.io/coverity/ondemand/jobs/JOB.svg</code></td>
</tr>
<tr><th> HHVM: </th>
<td><img src='/hhvm/symfony/symfony.svg' alt=''/></td>
<td><code>https://img.shields.io/hhvm/symfony/symfony.svg</code></td>