← back to roto on ba3a.dev

ProfileRepository

class ProfileRepository(library: Path, projectId: String)

The profiles of one project in the library folder: <library>/<projectId>/<profile id>/, each a ProfileFolder. The library lives outside every repository and is shared by all projects; the project id comes from the project's roto.json. Profile ids follow SafeName, since they become folder names and the {profile} value in output paths.

Constructors

Link copied to clipboard
constructor(library: Path, projectId: String)

Properties

Link copied to clipboard

<library>/<projectId>, holding one folder per profile.

Functions

Link copied to clipboard

Creates profile id with an empty sources/ and handoff/, and returns it. Fails if a profile with that id exists, even one differing only in case, which would share its folder on Windows.

Link copied to clipboard

Whether profile id has a profile.json.

Link copied to clipboard

The folder profile id lives in, whether or not it exists yet.

Link copied to clipboard
fun ids(): List<String>

The ids of every profile in the project, in sorted order; folders without a profile are skipped.

Link copied to clipboard
fun load(id: String, colours: ProjectPalette? = null): Profile

Reads profile id; a missing profile is a NoSuchFileException, a bad one a ProfileException. A variant's base is read too and must exist and not be a variant; with colours, the variant's ramps and outline are checked against them as well.

Link copied to clipboard
fun save(id: String, profile: Profile)

Replaces profile id's profile.json with profile, atomically.

Link copied to clipboard
fun updateClip(id: String, clipId: String, change: (Clip) -> Clip): Clip

Applies change to the clip clipId of profile id as profile.json holds it now, so nothing saved since the caller read the clip is lost; returns the clip as saved. A clip the profile no longer has is an IllegalArgumentException.