Skip to content

Commit

Permalink
Modernize some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow committed Dec 3, 2018
1 parent e3ad57d commit b7fa9a8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 31 deletions.
11 changes: 9 additions & 2 deletions services/teamcity/teamcity-coverage.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {
coveragePercentage: coveragePercentageColor,
} = require('../../lib/color-formatters')

// TeamCity CodeBetter code coverage.
module.exports = class TeamcityCoverage extends LegacyService {
static get category() {
return 'build'
Expand All @@ -15,18 +14,26 @@ module.exports = class TeamcityCoverage extends LegacyService {
static get route() {
return {
base: 'teamcity/coverage',
pattern: ':buildType',
}
}

static get examples() {
return [
{
title: 'TeamCity CodeBetter Coverage',
previewUrl: 'bt428',
namedParams: { buildType: 'bt428' },
staticPreview: { message: '55%', color: 'yellow' },
},
]
}

static get defaultBadgeData() {
return {
label: 'coverage',
}
}

static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/teamcity\/coverage\/(.*)\.(svg|png|gif|jpg|json)$/,
Expand Down
10 changes: 9 additions & 1 deletion services/travis/travis-php-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ module.exports = class TravisPhpVersion extends LegacyService {
static get route() {
return {
base: 'travis/php-v',
pattern: ':user/:repo',
}
}

static get defaultBadgeData() {
return {
label: 'php',
}
}

static get examples() {
return [
{
title: 'PHP from Travis config',
previewUrl: 'symfony/symfony',
namedParams: { user: 'symfony', repo: 'symfony' },
staticPreview: { message: '^7.1.3', color: 'blue' },
},
]
}
Expand Down
6 changes: 3 additions & 3 deletions services/uptimerobot/uptimerobot-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ module.exports = class UptimeRobotBase extends BaseJsonService {
}
}

async fetch({ monitorApiKey, numberOfDays }) {
this.constructor.ensureIsMonitorApiKey(monitorApiKey)
async fetch({ monitorSpecificKey, numberOfDays }) {
this.constructor.ensureIsMonitorApiKey(monitorSpecificKey)

let opts, schema
if (numberOfDays) {
Expand All @@ -80,7 +80,7 @@ module.exports = class UptimeRobotBase extends BaseJsonService {
'content-type': 'application/x-www-form-urlencoded',
},
form: {
api_key: monitorApiKey,
api_key: monitorSpecificKey,
format: 'json',
...opts,
},
Expand Down
16 changes: 10 additions & 6 deletions services/uptimerobot/uptimerobot-ratio.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,26 @@ module.exports = class UptimeRobotRatio extends UptimeRobotBase {
static get route() {
return {
base: 'uptimerobot/ratio',
pattern: ':numberOfDays(\\d+)?/:monitorApiKey',
pattern: ':numberOfDays(\\d+)?/:monitorSpecificKey',
}
}

static get examples() {
return [
{
title: 'Uptime Robot ratio (30 days)',
exampleUrl: 'm778918918-3e92c097147760ee39d02d36',
pattern: ':monitor-specific-key',
pattern: ':monitorSpecificKey',
namedParams: {
monitorSpecificKey: 'm778918918-3e92c097147760ee39d02d36',
},
staticExample: this.render({ ratio: 100 }),
},
{
title: 'Uptime Robot ratio (7 days)',
exampleUrl: '7/m778918918-3e92c097147760ee39d02d36',
pattern: '7/:monitor-specific-key',
namedParams: {
monitorSpecificKey: 'm778918918-3e92c097147760ee39d02d36',
},
staticExample: this.render({ ratio: 100 }),
},
]
Expand All @@ -43,8 +47,8 @@ module.exports = class UptimeRobotRatio extends UptimeRobotBase {
}
}

async handle({ numberOfDays = 30, monitorApiKey }) {
const { monitors } = await this.fetch({ monitorApiKey, numberOfDays })
async handle({ numberOfDays = 30, monitorSpecificKey }) {
const { monitors } = await this.fetch({ monitorSpecificKey, numberOfDays })
const ratio = Number.parseFloat(monitors[0].custom_uptime_ratio)
return this.constructor.render({ ratio })
}
Expand Down
12 changes: 7 additions & 5 deletions services/uptimerobot/uptimerobot-status.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ module.exports = class UptimeRobotStatus extends UptimeRobotBase {
static get route() {
return {
base: 'uptimerobot/status',
pattern: ':monitorApiKey',
pattern: ':monitorSpecificKey',
}
}

static get examples() {
return [
{
title: 'Uptime Robot status',
exampleUrl: 'm778918918-3e92c097147760ee39d02d36',
pattern: ':monitor-specific-key',
pattern: ':monitorSpecificKey',
namedParams: {
monitorSpecificKey: 'm778918918-3e92c097147760ee39d02d36',
},
staticExample: this.render({ status: 2 }),
},
]
Expand All @@ -44,8 +46,8 @@ module.exports = class UptimeRobotStatus extends UptimeRobotBase {
}
}

async handle({ monitorApiKey }) {
const { monitors } = await this.fetch({ monitorApiKey })
async handle({ monitorSpecificKey }) {
const { monitors } = await this.fetch({ monitorSpecificKey })
const { status } = monitors[0]
return this.constructor.render({ status })
}
Expand Down
48 changes: 42 additions & 6 deletions services/vaadin-directory/vaadin-directory.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,35 @@ class VaadinDirectoryRating extends LegacyService {
return [
{
title: 'Vaadin Directory',
previewUrl: 'rating/vaadinvaadin-grid',
pattern: 'rating/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'rating',
message: '5.0/5',
color: 'brightgreen',
},
keywords: ['vaadin-directory', 'vaadin directory', 'rating'],
},
{
title: 'Vaadin Directory',
previewUrl: 'stars/vaadinvaadin-grid',
pattern: 'stars/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'stars',
message: starRating(4.75),
color: 'brightgreen',
},
keywords: ['vaadin-directory', 'vaadin directory', 'star', 'stars'],
},
{
title: 'Vaadin Directory',
previewUrl: 'rating-count/vaadinvaadin-grid',
pattern: 'rating-count/:packageName',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'rating count',
message: '6 total',
color: 'yellow',
},
keywords: [
'vaadin-directory',
'vaadin directory',
Expand All @@ -59,14 +77,20 @@ class VaadinDirectoryVersion extends LegacyService {
static get route() {
return {
base: 'vaadin-directory/v',
pattern: ':packageName',
}
}

static get examples() {
return [
{
title: 'Vaadin Directory',
previewUrl: 'vaadinvaadin-grid',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'latest ver',
message: 'v5.3.0-alpha4',
color: '00b4f0',
},
keywords: [
'vaadin-directory',
'vaadin directory',
Expand All @@ -88,14 +112,20 @@ class VaadinDirectoryStatus extends LegacyService {
static get route() {
return {
base: 'vaadin-directory/status',
pattern: ':packageName',
}
}

static get examples() {
return [
{
title: 'Vaadin Directory',
previewUrl: 'vaadinvaadin-grid',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'vaadin directory',
message: 'published',
color: '00b4f0',
},
keywords: ['vaadin-directory', 'vaadin directory', 'status'],
},
]
Expand All @@ -112,14 +142,20 @@ class VaadinDirectoryReleaseDate extends LegacyService {
static get route() {
return {
base: 'vaadin-directory/release-date',
pattern: ':packageName',
}
}

static get examples() {
return [
{
title: 'Vaadin Directory',
previewUrl: 'vaadinvaadin-grid',
namedParams: { packageName: 'vaadinvaadin-grid' },
staticPreview: {
label: 'latest release date',
message: 'last wednesday',
color: 'brightgreen',
},
keywords: [
'vaadin-directory',
'vaadin directory',
Expand Down
32 changes: 24 additions & 8 deletions services/vscode-marketplace/vscode-marketplace.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const {
const { addv: versionText } = require('../../lib/text-formatters')
const { version: versionColor } = require('../../lib/color-formatters')

const keywords = ['vscode-marketplace']

//To generate API request Options for VS Code marketplace
function getVscodeApiReqOptions(packageName) {
return {
Expand Down Expand Up @@ -56,15 +58,17 @@ class VscodeMarketplaceDownloads extends LegacyService {
static get route() {
return {
base: 'vscode-marketplace/d',
pattern: ':repo',
}
}

static get examples() {
return [
{
title: 'Visual Studio Marketplace',
previewUrl: 'ritwickdey.LiveServer',
keywords: ['vscode-marketplace'],
namedParams: { repo: 'ritwickdey.LiveServer' },
staticPreview: { message: '1M', color: 'brightgreen' },
keywords,
},
]
}
Expand All @@ -87,13 +91,17 @@ class VscodeMarketplaceRating extends LegacyService {
return [
{
title: 'Visual Studio Marketplace',
previewUrl: 'r/ritwickdey.LiveServer',
keywords: ['vscode-marketplace'],
pattern: 'r/:repo',
namedParams: { repo: 'ritwickdey.LiveServer' },
staticPreview: { message: '4.79/5 (145)', color: 'brightgreen' },
keywords,
},
{
title: 'Visual Studio Marketplace',
previewUrl: 'stars/ritwickdey.LiveServer',
keywords: ['vscode-marketplace'],
pattern: 'stars/:repo',
namedParams: { repo: 'ritwickdey.LiveServer' },
staticPreview: { message: starRating(4.75), color: 'brightgreen' },
keywords,
},
]
}
Expand All @@ -109,15 +117,23 @@ class VscodeMarketplaceVersion extends LegacyService {
static get route() {
return {
base: 'vscode-marketplace/v',
pattern: ':repo',
}
}

static get defaultBadgeData() {
return {
label: 'visual studio marketplace',
}
}

static get examples() {
return [
{
title: 'Visual Studio Marketplace',
previewUrl: 'ritwickdey.LiveServer',
keywords: ['vscode-marketplace'],
namedParams: { repo: 'ritwickdey.LiveServer' },
staticPreview: { message: 'v5.2.0', color: 'blue' },
keywords,
},
]
}
Expand Down

0 comments on commit b7fa9a8

Please sign in to comment.