Skip to content
Browse files

Add CocoaPods version integration

  • Loading branch information...
1 parent bf839e8 commit e4c7a30f07e938b202150ec6648a01df56aced32 @akashivskyy akashivskyy committed Mar 12, 2014
Showing with 37 additions and 0 deletions.
  1. +33 −0 server.js
  2. +4 −0 try.html
View
33 server.js
@@ -575,6 +575,39 @@ cache(function(data, match, sendBadge) {
});
}));
+// CocoaPods version integration.
+camp.route(/^\/cocoapods\/v\/(.*)\.(svg|png|gif|jpg)$/,
+cache(function(data, match, sendBadge) {
+ var spec = match[1];
+ var format = match[2];
+ var apiUrl = 'http://search.cocoapods.org/api/v1/pod/' + spec + '.json';
+ var badgeData = getBadgeData('pod', data);
+ request(apiUrl, function(err, res, buffer) {
+ if (err != null) {
+ badgeData.text[1] = 'inaccessible';
+ sendBadge(format, badgeData);
+ }
+ try {
+ var data = JSON.parse(buffer);
+ var version = data.version;
+ version = version.replace(/^v/, "");
+ badgeData.text[1] = version;
+ if (/^\d/.test(badgeData.text[1])) {
+ badgeData.text[1] = 'v' + version;
+ }
+ if (version[0] === '0' || /dev/.test(version)) {
+ badgeData.colorscheme = 'orange';
+ } else {
+ badgeData.colorscheme = 'blue';
+ }
+ sendBadge(format, badgeData);
+ } catch(e) {
+ badgeData.text[1] = 'invalid';
+ sendBadge(format, badgeData);
+ }
+ });
+}));
+
// Any badge.
camp.route(/^\/(:|badge\/)(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+)\.(svg|png|gif|jpg)$/,
function(data, match, end, ask) {
View
4 try.html
@@ -156,6 +156,10 @@
<td><img src='/packagist/v/symfony/symfony.svg' alt=''/></td>
<td><code>http://img.shields.io/packagist/v/symfony/symfony.svg</code></td>
</tr>
+ <tr><th> CocoaPods: </th>
+ <td><img src='/cocoapods/v/AFNetworking.svg' alt='' /></td>
+ <td><code>http://img.shields.io/cocoapods/v/AFNetworking.svg</code></td>
+ </tr>
</tbody></table>
<h2> Like This? </h2>

0 comments on commit e4c7a30

Please sign in to comment.
Something went wrong with that request. Please try again.