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
Paul Melnikow 02ec19fd22 BaseService terminology: Rename url to route (#2278)
The term “url” is overloaded in services, to refer to the Shields route and also the API URL. Calling the Shields URL a “route” is on the whole more descriptive, and makes it clearer and more obvious which one of these we’re talking about. It’s a small thing, though seems like an improvement.

We have a few functions called `buildUrl`. I’ve renamed them to `buildRoute` when they refer to routes, and left them as `buildUrl` when they refer to API URLs.

I included a minor style tweak and some formatting cleanup in `TUTORIAL.md`.
2018-11-09 15:11:03 -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 'other'
}
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 })
}
}