1
0
mirror of https://github.com/badges/shields.git synced 2025-11-09 12:40:59 +03:00
Files
shields/services/pypi/pypi-implementation.service.js
2018-12-05 14:17:37 -05:00

51 lines
1.0 KiB
JavaScript

'use strict'
const PypiBase = require('./pypi-base')
const { parseClassifiers } = require('./pypi-helpers')
module.exports = class PypiImplementation extends PypiBase {
static get category() {
return 'platform-support'
}
static get route() {
return this.buildRoute('pypi/implementation')
}
static get defaultBadgeData() {
return { label: 'implementation' }
}
static get examples() {
return [
{
title: 'PyPI - Implementation',
previewUrl: 'Django',
keywords: ['python'],
},
]
}
static render({ implementations }) {
return {
message: implementations.sort().join(' | '),
color: 'blue',
}
}
async handle({ egg }) {
const packageData = await this.fetch({ egg })
let implementations = parseClassifiers(
packageData,
/^Programming Language :: Python :: Implementation :: (\S+)$/
)
if (implementations.length === 0) {
// Assume CPython.
implementations = ['cpython']
}
return this.constructor.render({ implementations })
}
}