Lmml.Manifest (Lmml v0.1.0)

View Source

Optional manifest.json metadata for a Lmml.Bundle.

manifest.json is not a distinct front-matter mechanism -- it is simply an embed literally named "manifest.json", exactly like any other embed: @@@manifest.json ... @@@ inline, or @manifest.json referencing a zip entry inside a .lmmlz. This module looks that embed up, decodes it with OTP's built-in :json (not Jason), and exposes its top-level fields as a plain map.

A bundle mentioning no manifest.json embed at all has no manifest -- that is a normal, fully-supported, non-error state (load/1 returns {:ok, nil}), not something to special-case at every call site.

Summary

Functions

Fetches a top-level key from the manifest's decoded data, or nil if absent.

Loads and decodes bundle's manifest.json embed, if any.

Same as load/1, but raises on failure. A manifest-less bundle still returns nil, not an exception.

The reserved embed name a bundle's manifest is looked up by, if present.

Types

t()

@type t() :: %Lmml.Manifest{data: map()}

Functions

get(manifest, key)

@spec get(t(), String.t()) :: term() | nil

Fetches a top-level key from the manifest's decoded data, or nil if absent.

load(bundle)

@spec load(Lmml.Bundle.t()) :: {:ok, t() | nil} | {:error, term()}

Loads and decodes bundle's manifest.json embed, if any.

Returns:

  • {:ok, %Lmml.Manifest{}} -- a manifest.json embed exists and decodes to a JSON object.
  • {:ok, nil} -- no manifest.json embed is mentioned anywhere in the narrative. This is the common case for a manifest-less bundle, not an error.
  • {:error, reason} -- a manifest.json embed is mentioned, but either its content is unresolvable (e.g. an @manifest.json reference in a bare .lmml, or a dangling reference into a .lmmlz's entries -- see Lmml.Bundle.embed/2), or its resolved content is not valid JSON, or it decodes to something other than a JSON object ({:invalid_manifest, reason}).

load!(bundle)

@spec load!(Lmml.Bundle.t()) :: t() | nil

Same as load/1, but raises on failure. A manifest-less bundle still returns nil, not an exception.

name()

@spec name() :: String.t()

The reserved embed name a bundle's manifest is looked up by, if present.