YAMLish - a YAML parser/emitter written in pure raku
This is a YAML parser written in pure-raku. It aims at being feature complete (though there still a few features left to implement). Patches are welcome.
$ zef install YAMLish
-
load-yaml(Str $input, ::Grammar:U :$schema = ::Schema::Core, :%tags)
-
load-yamls(Str $input, ::Grammar:U :$schema = ::Schema::Core, :%tags)
-
save-yaml($document, :$sorted = True)
-
save-yamls(**@documents, :$sorted = True)
This configuration file begins with a comment followed by three lines of key/value:
# key: value
lang: en
lat: 46.12345
lon: -82.6231
Access the file in your code like this:
use YAMLish;
my $str = "config.yml".IO.slurp:
my %conf = load-yaml $str;
say %conf<lang>; # OUTPUT: «en»
say %conf<lat>; # OUTPUT: «46.12345»
say %conf<lon>; # OUTPUT: «-82.6231»
Please have a look at ./TODO.md
Leon Timmermans
Artistic License 2.0