Skip to content

Commit

Permalink
Merge remote-tracking branch 'erichoracek/add-cocoapods-doc-percent'
Browse files Browse the repository at this point in the history
  • Loading branch information
espadrine committed Oct 12, 2015
2 parents f8ba6b0 + a996e9c commit f207b4f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,32 @@ cache(function(data, match, sendBadge, request) {
});
}));

camp.route(/^\/cocoapods\/metrics\/doc-percent\/(.*)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var spec = match[1]; // eg, AFNetworking
var format = match[2];
var apiUrl = 'http://metrics.cocoapods.org/api/v1/pods/' + spec;
var badgeData = getBadgeData('pod', data);
request(apiUrl, function(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var data = JSON.parse(buffer);
var percentage = data.cocoadocs.doc_percent;
badgeData.colorscheme = coveragePercentageColor(percentage);
badgeData.text[0] = 'docs';
badgeData.text[1] = percentage + '%'
sendBadge(format, badgeData);
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
}
});
}));

// GitHub tag integration.
camp.route(/^\/github\/tag\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
Expand Down
4 changes: 4 additions & 0 deletions try.html
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ <h3 id="miscellaneous"> Longer Miscellaneous </h3>
<td><img src='/cocoapods/p/AFNetworking.svg' alt='' /></td>
<td><code>https://img.shields.io/cocoapods/p/AFNetworking.svg</code></td>
</tr>
<tr><th> CocoaPods: </th>
<td><img src='/cocoapods/metrics/doc-percent/AFNetworking.svg' alt='' /></td>
<td><code>https://img.shields.io/cocoapods/metrics/doc-percent/AFNetworking.svg</code></td>
</tr>
<tr><th> Ansible Role: </th>
<td><img src='/ansible/role/3078.svg' alt=''/></td>
<td><code>https://img.shields.io/ansible/role/3078.svg</code></td>
Expand Down

0 comments on commit f207b4f

Please sign in to comment.