NAME
Math::Formula::Config::YAML - load/save formulas to file in YAML
INHERITANCE
Math::Formula::Config::YAML
is a Math::Formula::Config
SYNOPSIS
my $context = Math::Formula::Content->new(name => 'test');
my $config = Math::Formula::Config::YAML->new(directory => $dir);
$config->save($context);
my $context = $config->load('test');
DESCRIPTION
Write a Context to file, and read it back again.
The attributes, formulas, and fragments are written as three separate documents.
You need to have installed YAML::XS, minimal version 0.81 (for security reasons) and module boolean.pm
. They are not in the dependencies of this packages, because we do not want to add complications to the main code.
Extends "DESCRIPTION" in Math::Formula::Config.
METHODS
Extends "METHODS" in Math::Formula::Config.
Constructors
Extends "Constructors" in Math::Formula::Config.
- Math::Formula::Config::YAML->new(%options)
-
Inherited, see "Constructors" in Math::Formula::Config
Attributes
Extends "Attributes" in Math::Formula::Config.
- $obj->directory()
-
Inherited, see "Attributes" in Math::Formula::Config
- $obj->path_for($file)
-
Inherited, see "Attributes" in Math::Formula::Config
Actions
Extends "Actions" in Math::Formula::Config.
- $obj->load($name, %options)
-
Load a Math::Formula::Context for a yml file.
-Option --Default filename <directory/$name.yml>
- $obj->save($context, %args)
-
Serialize the $context to YAML files, as storage or to be edited by hand. This is a useful method when default configuration templates need to be generated.
-Option --Default filename C<< $context->name .yml>
DETAILS
YAML has a super powerful syntax, which natively supports integers, floats, booleans, and strings. But it can do so much more! (What we are not gonna use (yet))
The Context's attributes are in the first document. The formulas are in the second document. The fragments will get a place in the third document (but are not yet supported).
On Perl, you will need YAML::XS to be able to treat booleans correctly. For instance, YAML.pm
will create a string with content 'true' without quotes... which makes it a boolean.
. Example
---
created: =2023-02-27T15:54:54+0000
mf_version: ''
name: test
updated: =2023-02-27T15:54:54+0000
version: '1.00'
---
expr1: =1 + 2 * 3
expr2: ="abc".size + 3k; returns='MF::INTEGER'
fakes: false
float: 3.14
int: 42
longer: abc def yes no
no_quotes: abc
some_truth: true
string: 'true'
---
SEE ALSO
This module is part of Math-Formula distribution version 0.16, built on March 14, 2023. Website: http://perl.overmeer.net/CPAN/
LICENSE
Copyrights 2023 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/