mighty-gerbils / gerbil-libyaml

Gerbil LibYAML bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Gerbil LibYAML bindings

License:GNU Lesser General Public License v2.1


Languages

Language:Scheme 100.0%