Gerbil LibYAML bindings
Find a file
2023-09-23 15:14:58 +03:00
text fix ssi loader 2023-09-23 15:14:58 +03:00
.gitignore moved from stdlib 2023-09-23 15:13:34 +03:00
build.ss moved from stdlib 2023-09-23 15:13:34 +03:00
gerbil.pkg moved from stdlib 2023-09-23 15:13:34 +03:00
LICENSE-APACHE-2.0.txt moved from stdlib 2023-09-23 15:13:34 +03:00
LICENSE-LGPL.txt moved from stdlib 2023-09-23 15:13:34 +03:00
README.md moved from stdlib 2023-09-23 15:13:34 +03:00

Gerbil YAML Processor

This package provides a Gerbil YAML processor using liblmdb.

Dependencies

You need to have libyaml installed in your system.

In ubuntu:

$ sudo apt install libyaml-dev

Installation

To install the package in your $GERBIL_PATH (~/.gerbil by default):

$ gerbil pkg install github.com/mighty-gerbils/gerbil-libyaml

API

To use bindings from this package:

(import :clan/text/yaml)

yaml-key-format

(yaml-key-format) -> formatter
(yaml-key-format new-formatter) -> old-formatter

A parameter that controls how string keys are stored in mappings. YAML allows non-string keys in mappings (e.g. numbers, sequences, and other mappings). These are not affected by this parameter.

No conversion is done by default.

To convert map keys to symbols:

> (parameterize ((yaml-key-format string->symbol))
   (hash-keys (car (yaml-load-string "foo: bar"))))
(foo)

To convert map keys to keywords:

> (parameterize ((yaml-key-format string->keyword))
   (hash-keys (car (yaml-load-string "foo: bar"))))
(foo:)

yaml-load

(yaml-load filename) -> any | error
  filename := string

Loads a YAML data from given filename. Signals an error if fails to parse YAML.

yaml-load-string

(yaml-load-string str) -> any | error
  str := string of YAML data

Parses a YAML data from str. Signals an error if fails to parse YAML.

yaml-dump

(yaml-dump filename . args)
  filename := string

Dumps the arguments to a YAML file.

License and Copyright

© 2017-2023 The Gerbil Core Team and contributors; License: LGPLv2.1 and Apache 2.0

Originally written by vyzo.