* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Autofixes
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const { floorCount: floorCountColor } = require('../color-formatters')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
const ownerSchema = Joi.array().required()
|
|
|
|
module.exports = class GemOwner extends BaseJsonService {
|
|
static get category() {
|
|
return 'other'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'gem/u',
|
|
pattern: ':user',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Gems',
|
|
namedParams: { user: 'raphink' },
|
|
staticPreview: this.render({ count: 34 }),
|
|
keywords: ['ruby'],
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'gems' }
|
|
}
|
|
|
|
static render({ count }) {
|
|
return {
|
|
message: count,
|
|
color: floorCountColor(count, 10, 50, 100),
|
|
}
|
|
}
|
|
|
|
async fetch({ user }) {
|
|
const url = `https://rubygems.org/api/v1/owners/${user}/gems.json`
|
|
return this._requestJson({
|
|
url,
|
|
schema: ownerSchema,
|
|
})
|
|
}
|
|
|
|
async handle({ user }) {
|
|
const json = await this.fetch({ user })
|
|
return this.constructor.render({ count: json.length })
|
|
}
|
|
}
|