module

AmebaConfig::YamlValue

Helpers for converting between Crystal scalars and YAML::Any, and for rendering YAML::Any values into the output format we want for .ameba.yml.

Constants

INLINE_ARRAY_MAX_WIDTH = 80

Maximum line width for inline ([a, b, c]) array rendering when an array sits to the right of key:. Arrays whose inline form would exceed this width fall back to block (- a / - b / - c) form.

Instance methods

equal?(left : YAML::Any, right : YAML::Any) : Bool

Compare two YAML::Any values for "logical" equality (raw-level).

Source
parse_scalar(input : String) : YAML::Any

Parse a user-supplied scalar from the CLI (e.g. set Foo/Bar Setting=value) into a YAML::Any. Recognises true/false/nil/integers/floats/~, otherwise treats the value as a string. Quoted strings ("..." or '...') are unwrapped.

Source
render(value : YAML::Any, indent : Int32) : String

Render a YAML::Any value as it should appear on the right-hand side of key: value (for scalars) or, if too complex, as a multi-line YAML subtree indented under the key.

Returns a String, possibly multi-line. The first line never has any leading indent — the caller writes key: <result> for scalars and key:\n<result> for collections.

Source
render_pair(io : IO, key : String, value : YAML::Any, indent : Int32) : Nil

Convenience: render a key: value (or key:\n ...) pair as a multi-line string at the given indent. Includes a trailing newline. Arrays of scalar elements are rendered inline ([a, b, c]) when the resulting line fits within INLINE_ARRAY_MAX_WIDTH; otherwise they drop to block form.

Source