The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Venus::Yaml - Yaml Class

ABSTRACT

Yaml Class for Perl 5

SYNOPSIS

package main;

use Venus::Yaml;

my $yaml = Venus::Yaml->new(
  value => { name => ['Ready', 'Robot'], version => 0.12, stable => !!1, }
);

# $yaml->encode;

DESCRIPTION

This package provides methods for reading and writing YAML data. Note: This package requires that a suitable YAML library is installed, currently either YAML::XS 0.67+, YAML::PP::LibYAML 0.004+, or YAML::PP 0.23+. You can use the VENUS_YAML_PACKAGE environment variable to include or prioritize your preferred YAML library.

ATTRIBUTES

This package has the following attributes:

decoder

decoder(CodeRef)

This attribute is read-write, accepts (CodeRef) values, and is optional.

encoder

encoder(CodeRef)

This attribute is read-write, accepts (CodeRef) values, and is optional.

INHERITS

This package inherits behaviors from:

Venus::Kind::Utility

INTEGRATES

This package integrates behaviors from:

Venus::Role::Accessible

Venus::Role::Buildable

Venus::Role::Explainable

Venus::Role::Valuable

METHODS

This package provides the following methods:

decode

decode(string $yaml) (any)

The decode method decodes the YAML string, sets the object value, and returns the decoded value.

Since 0.01

decode example 1
# given: synopsis;

my $decode = $yaml->decode("codename: ['Ready','Robot']\nstable: true");

# { codename => ["Ready", "Robot"], stable => 1 }

encode

encode() (string)

The encode method encodes the objects value as a YAML string and returns the encoded string.

Since 0.01

encode example 1
# given: synopsis;

my $encode = $yaml->encode;

# "---\nname:\n- Ready\n- Robot\nstable: true\nversion: 0.12\n"

ERRORS

This package may raise the following errors:

error: error_on_config

This package may raise an error_on_config exception.

example 1

# given: synopsis;

my $input = {
  throw => 'error_on_config',
};

my $error = $yaml->catch('error', $input);

# my $name = $error->name;

# "on_config"

# my $message = $error->message;

# "No suitable YAML package"

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2022, Awncorp, awncorp@cpan.org.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.