Token reference expansion for DTCG brace references and JSON pointers.
Handles {ref.path} brace references, #/json/pointer references,
and embedded references within string values. Provides error suggestions
for mistyped reference paths.
Summary
Functions
Finds the closest match to target among candidates using Jaro distance.
Expands all {ref.path} references in a token list.
Extracts the dot-path from a brace reference like {color.brand.primary}.
Returns true if the value is a single full brace reference like {color.brand.primary}.
Functions
Finds the closest match to target among candidates using Jaro distance.
Returns the best match if its score exceeds 0.8, otherwise nil.
Examples
iex> Jetons.Ref.closest("colors.rd", ["colors.red", "colors.blue", "spacing.sm"])
"colors.red"
iex> Jetons.Ref.closest("xyz", ["colors.red", "colors.blue"])
nil
Expands all {ref.path} references in a token list.
Takes a list of {path, value} tuples and returns a new list where
all reference values have been replaced with their resolved values.
Raises ArgumentError on circular or missing references.
Examples
iex> Jetons.Ref.expand([{"colors.primary", "#f00"}, {"colors.alias", "{colors.primary}"}])
[{"colors.primary", "#f00"}, {"colors.alias", "#f00"}]
Extracts the dot-path from a brace reference like {color.brand.primary}.
Examples
iex> Jetons.Ref.path("{colors.primary}")
"colors.primary"
Returns true if the value is a single full brace reference like {color.brand.primary}.
Examples
iex> Jetons.Ref.ref?("{colors.primary}")
true
iex> Jetons.Ref.ref?("not a ref")
false
iex> Jetons.Ref.ref?("{a} and {b}")
false