Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Parser

A base class for language parsers

A language Parser generates a JSON-LD SoftwarePackage instance based on the contents of a directory. It is responsible for determining which packages the application needs, resolving the dependencies of those packages (both system and language packages) and turning those into a JSON-LD SoftwarePackage instance.

If the Parser finds a corresponding requirements file for the language (e.g. requirements.txt for Python), then it uses that to determine the language packages to install. If no requirements file is found, it scans for source code files for package import statements (e.g. library(package) in .R files), generates a package list from those statements and creates a requirements file.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

folder

folder: string

The directory to scan for relevant files

Protected Readonly urlFetcher

urlFetcher: UrlFetcher

The instance of IUrlFetcher to fetch URLs

Methods

exists

  • exists(subpath: string): boolean
  • Does a path exist within the project folder?

    Parameters

    • subpath: string

      The path within the folder

    Returns boolean

fetch

  • fetch(url: string, options?: any): Promise<any>
  • Fetch content from a URL

    Parameters

    • url: string

      The URL to fetch

    • Default value options: any = { responseType: 'json' }

      Request options

    Returns Promise<any>

glob

  • glob(pattern: string | Array<string>): Array<string>
  • Get a list of paths that match a pattern in the project folder.

    Parameters

    • pattern: string | Array<string>

      The glob pattern

    Returns Array<string>

Abstract parse

  • parse(): Promise<SoftwarePackage | null>
  • Parse the project folder

    Returns Promise<SoftwarePackage | null>

read

  • read(subpath: string): string
  • Read a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    Returns string

write

  • write(subpath: string, content: string): void
  • Write to a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    • content: string

      The content to write to the file

    Returns void

Generated using TypeDoc