Class: BaseSvgScrapingService

(abstract) core/base-service/base-svg-scraping~BaseSvgScrapingService()

Services which scrape data from another SVG badge should extend BaseSvgScrapingService

Constructor

(abstract) new BaseSvgScrapingService()

Source:

Methods

(async) _requestSvg(attrs) → {object}

Request data from an endpoint serving SVG, parse a value from it and validate against a schema

Parameters:
Name Type Description
attrs object

Refer to individual attrs

Properties
Name Type Attributes Default Description
schema Joi

Joi schema to validate the response against

valueMatcher RegExp

RegExp to match the value we want to parse from the SVG

url string

URL to request

options object <optional>
{}

Options to pass to got. See documentation

errorMessages object <optional>
{}

Key-value map of status codes and custom error messages e.g: { 404: 'package not found' }. This can be used to extend or override the default

Source:
See:
Returns:

Parsed response

Type
object

(static) valueFromSvgBadge(svg, valueMatcheropt) → {string}

Extract a value from SVG

Parameters:
Name Type Attributes Default Description
svg string

SVG to parse

valueMatcher RegExp <optional>
defaultValueMatcher

RegExp to match the value we want to parse from the SVG

Source:
Returns:

Matched value

Type
string