module KYAML

Overview

Version constant for the KYAML shard.

Defined in:

kyaml.cr
kyaml/builder.cr
kyaml/classifier.cr
kyaml/emitter.cr
kyaml/error.cr
kyaml/parser.cr
kyaml/scalar.cr
kyaml/serializable.cr
kyaml/to_kyaml.cr
kyaml/version.cr

Constant Summary

BUILD_DATE = {{ (`date +%F`).stringify.chomp }}
BUILD_HASH = {{ (`git rev-parse HEAD`).stringify[0...8] }}
VERSION = {{ (`shards version /home/runner/work/kyaml/kyaml/src/kyaml/..`).stringify.chomp }}

Build metadata constants generated at compile time

Class Method Summary

Class Method Detail

def self.build(io : IO, & : Builder -> ) : Nil #

Builds KYAML imperatively, writing to io.


[View source]
def self.build(& : Builder -> ) : String #

Builds KYAML imperatively, returning as a String.


[View source]
def self.emit(value : KYAML::Any::Type, io : IO) : Nil #

Emits value as KYAML to io


[View source]
def self.emit(object, io : IO) : Nil #

Emits an arbitrary basic typed object as KYAML to io.

Accepts scalar and collection types and normalizes them into the KYAML::Any::Type union, delegating to the KYAML::Emitter.

Structs are out of scope here, use the (pending) KYAML::Serializable instead.


[View source]
def self.emit(value : KYAML::Any::Type) : String #

Emits value as KYAML and returns it as a String


[View source]
def self.emit(object) : String #

Emits an arbitrary basic typed object as KYAML to io.

Accepts scalar and collection types and normalizes them into the KYAML::Any::Type union, delegating to the KYAML::Emitter.

Structs are out of scope here, use the (pending) KYAML::Serializable instead.


[View source]
def self.emit_all(objects : Enumerable, io : IO) : Nil #

Emits each element of objects as its own KYAML doc to io.

An empty collection generates no output.


[View source]
def self.emit_all(objects : Enumerable) : String #

Emits each element of objects as its own KYAML doc to io.

An empty collection generates no output.


[View source]
def self.emit_all_docs(docs : Enumerable(KYAML::Doc), io : IO) : Nil #

Emits each KYAML::Doc in docs as a complete KYAML document to io.


[View source]
def self.emit_all_docs(docs : Enumerable(KYAML::Doc)) : String #

Emits all KYAML::Doc in docs as a complete KYAML document and returns it as a String.


[View source]
def self.emit_doc(doc : KYAML::Doc, io : IO) : Nil #

Emits doc as a complete KYAML document to io, including any preserved comments.


[View source]
def self.emit_doc(doc : KYAML::Doc) : String #

Emits doc as a complete KYAML document and returns it as a String.


[View source]
def self.normalize(value : Nil) : KYAML::Any::Type #

Normalizes a basic typed value into the KYAML::Any::Type union so the emitter can render it. Recurses through Arrays and Hashes.


[View source]
def self.parse(input : String | IO, *, strict : Bool = false) : KYAML::Any #

Parses a single K/YAML doc into a KYAML::Any.

Lenient mode: Default, accepts any valid YAML input. Only enforces that mapping keys are scalars, raises KYAML::NonStringKeyError on violation

Strict mode: (strict: true) rejects block-style sequences+mappings, block scalars (|, >), YAML tags, anchors, and aliases. Each raises a dedicated KYAML::StrictError subclass.

Raises KYAML::ParseError on malformed YAML.


[View source]
def self.parse_all(input : String | IO, *, strict : Bool = false, & : KYAML::Any -> ) : Nil #

Parses a multi-doc K/YAML stream, block variant. Yields each doc into a KYAML::Any.

Each doc is validated independently, a violation raised in doc N raises immediately and does not yield docs 0..N-1 back to the block.


[View source]
def self.parse_all(input : String | IO, *, strict : Bool = false) : Array(KYAML::Any) #

Parses a multi-doc K/YAML stream, non-block variant.

Returns an Array(KYAML::Any) of all docs.


[View source]
def self.parse_all_docs(input : String | IO, *, strict : Bool = false, & : KYAML::Doc -> ) : Nil #

Parses a multi-doc K/YAML stream, block variant. Yields each doc as a KYAML::Doc. Each doc owns only its own comments, the scanner partitions the full comment list per doc by --- separator.

Each doc is validated independently, a violation raised in doc N raises immediately and does not yield docs 0..N-1 back to the block.

If you don't need comments then use KYAML.parse_all instead.


[View source]
def self.parse_all_docs(input : String | IO, *, strict : Bool = false) : Array(KYAML::Doc) #

Parses a multi-doc K/YAML stream, non-block variant. If you don't need comments then use KYAML.parse_all instead.

Returns an Array(KYAML::Doc) of all parsed docs.


[View source]
def self.parse_doc(input : String | IO, *, strict : Bool = false) : KYAML::Doc #

Parses a single K/YAML doc, returning a tree+comments KYAML::Doc.

This is the comment-preserving entrypoint, where the returned Doc holds both a parsed K/YAML doc tree and its sister sidecar comments.

If you don't need comments then use KYAML.parse instead.

Follows the same lenient/strict modes as .parse.


[View source]