LEPTRIS

Yeptris — the YAML gem v0.6.22.1

An FFI binding (no C extension, zero compilation at install) over libyeptris v0.6.22. API shape and value semantics mirror Psych: YAML 1.1 implicit typing by default, the Psych error hierarchy, and a drop-in namespace.

Installation

bash
gem install yeptris

RubyGems resolves a prebuilt platform gem where one exists: fat gems for x86_64/aarch64 Linux (glibc and musl), macOS (x86_64/arm64) and Windows (mingw and ucrt) — 14 release legs, lockstep-versioned with the engine. The gem binds the sharedlibyeptris through FFI: nothing compiles at install.

Usage

ruby
require "yeptris"

Yeptris::YAML.load("name: yeptris\nrating: 10\n")
# => {"name" => "yeptris", "rating" => 10}

# Psych's YAML 1.1 implicit typing is the default (yes => true, 017 => 15);
# pass schema: :core_12 for YAML 1.2 core semantics
Yeptris::YAML.load(src, schema: :core_12)

Yeptris::YAML.dump({"name" => "yeptris", "tags" => [:yaml, :fast]})

begin
  Yeptris::YAML.load("a: [1,")
rescue Yeptris::ParseError => e
  e.message   # carries the C parser's line/column detail
end

Dump builds through the library’s DOM mutation API, so the C emitter’s sizing, style-choosing and escape machinery applies to synthesized trees unchanged. Handles are document-scoped:Document#free releases everything in one C call, a GC finalizer backs it up, and any use after free raisesYeptris::FreedError — never a segfault.

The strict-JSON twin

Yeptris::YAML.load keeps the Psych contract for every input — including JSON-shaped ones ({"a": [1,]} is legal flow YAML; "1e3" is a Psych String).Yeptris::JSON.load is the strict RFC 8259 surface — exact JSON.parse semantics by construction, spec-pinned value-by-value and error-by-error:

ruby
require "yeptris/json"

Yeptris::JSON.load('{"a": [1, 2], "b": null, "c": 1e3}')
# => {"a" => [1, 2], "b" => nil, "c" => 1000.0}
# Bignum integers, exponent-only floats, duplicate-key semantics:
# every case shares JSON.parse's contract by test, not by claim.

The Document node API

ruby
doc = Yeptris::Document.parse(config_yaml)
doc.root["server"]["port"].to_i
doc.serialize                    # canonical YAML through the C emitter
doc.free                         # one C call; FreedError afterwards

Psych drop-in

Yeptris::Psych re-implements Psych’s surface over the engine, and the error names consumers rescue are aliased at the top level — Yeptris::DisallowedClass isYeptris::Psych::DisallowedClass. Informational notices are opt-in (YEPTRIS_DEBUG=1): a successful fallback is not a warning, and consumer CLIs that assert clean stderr stay clean by default.

This is the curated guide. The repositories are canonical: when this page and the repo disagree, the repo wins. Full documentation lives with the source.