PtcRunner.Kernel.ExampleLibrary (PtcRunner v0.14.0)

Copy Markdown View Source

Runnable example projects embedded at compile time and materialized by ptc init DIRECTORY --example NAME.

The documentation prints ptc run examples/… commands. A release is a bare Mix release tree that copies no examples/ directory, so those commands read as runnable and are not — and even in a checkout they work from exactly one directory. Each example is therefore embedded the way documentation pages are, and ptc init --example writes the tree wherever the caller asks for it.

A tree is embedded from its checked-in files. .env stubs are generated from host credential declarations when a project names an env_file, and a .gitignore is generated when the tree has none, so a materialized copy can run without a checkout. Paths inside the tree stay valid because nothing is rewritten and nothing is flattened.

Summary

Functions

Returns the sorted top-level entries ptc init --example NAME creates.

Returns one example's files as a map of tree-relative path to exact content.

Returns the public listing of embedded examples, in catalog order.

Returns every embedded example name, in catalog order.

Functions

created(name)

@spec created(binary()) :: {:ok, [binary()]} | :error

Returns the sorted top-level entries ptc init --example NAME creates.

The command envelope seals this list per example, the way it seals the scaffold's own, so a published tree cannot quietly gain or lose a top-level entry.

fetch(name)

@spec fetch(binary()) :: {:ok, %{required(binary()) => binary()}} | :error

Returns one example's files as a map of tree-relative path to exact content.

Examples

iex> {:ok, files} = PtcRunner.Kernel.ExampleLibrary.fetch("llm-replay")
iex> Map.has_key?(files, "replay.jsonl")
true

iex> PtcRunner.Kernel.ExampleLibrary.fetch("nonexistent")
:error

listing()

@spec listing() :: [map()]

Returns the public listing of embedded examples, in catalog order.

names()

@spec names() :: [binary()]

Returns every embedded example name, in catalog order.