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
@type t() :: %Lmml.Manifest{data: map()}
Functions
Fetches a top-level key from the manifest's decoded data, or nil if absent.
@spec load(Lmml.Bundle.t()) :: {:ok, t() | nil} | {:error, term()}
Loads and decodes bundle's manifest.json embed, if any.
Returns:
{:ok, %Lmml.Manifest{}}-- amanifest.jsonembed exists and decodes to a JSON object.{:ok, nil}-- nomanifest.jsonembed is mentioned anywhere in the narrative. This is the common case for a manifest-less bundle, not an error.{:error, reason}-- amanifest.jsonembed is mentioned, but either its content is unresolvable (e.g. an@manifest.jsonreference in a bare.lmml, or a dangling reference into a.lmmlz's entries -- seeLmml.Bundle.embed/2), or its resolved content is not valid JSON, or it decodes to something other than a JSON object ({:invalid_manifest, reason}).
@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.
@spec name() :: String.t()
The reserved embed name a bundle's manifest is looked up by, if present.