1Config::Model::Backend:U:sYearmlC(o3n)tributed Perl DocuCmoennftiagt:i:oMnodel::Backend::Yaml(3)
2
3
4

NAME

6       Config::Model::Backend::Yaml - Read and write config as a YAML data
7       structure
8

VERSION

10       version 2.134
11

SYNOPSIS

13        use Config::Model ;
14        use Data::Dumper ;
15
16        # define configuration tree object
17        my $model = Config::Model->new ;
18        $model ->create_config_class (
19           name => "MyClass",
20           element => [
21               [qw/foo bar/] => {
22                   type => 'leaf',
23                   value_type => 'string'
24               },
25               baz => {
26                   type => 'hash',
27                   index_type => 'string' ,
28                   cargo => {
29                       type => 'leaf',
30                       value_type => 'string',
31                   },
32               },
33           ],
34         rw_config  => {
35           backend => 'yaml',
36           config_dir => '/tmp',
37           file  => 'foo.yml',
38           auto_create => 1,
39         }
40        ) ;
41
42        my $inst = $model->instance(root_class_name => 'MyClass' );
43
44        my $root = $inst->config_root ;
45
46        my $steps = 'foo=yada bar="bla bla" baz:en=hello
47                    baz:fr=bonjour baz:hr="dobar dan"';
48        $root->load( steps => $steps ) ;
49        $inst->write_back ;
50
51       Now, "/tmp/foo.yml" contains:
52
53        ---
54        bar: bla bla
55        baz:
56          en: hello
57          fr: bonjour
58          hr: dobar dan
59        foo: yada
60

DESCRIPTION

62       This module is used directly by Config::Model to read or write the
63       content of a configuration tree written with YAML syntax in
64       "Config::Model" configuration tree.
65
66       Note:
67
68       •   Undefined values are skipped for list element. I.e. if a list
69           element contains "('a',undef,'b')", the data structure contains
70           'a','b'.
71
72       •   YAML file is not created (and may be deleted) when no data is to be
73           written.
74
75   Class with only one hash element
76       If the root node contains a single hash or list element, only the
77       content of this hash is written in a YAML file.
78
79       For example, if a class contains:
80
81             element => [
82               baz => {
83                   type => 'hash',
84                   index_type => 'string' ,
85                   cargo => {
86                       type => 'leaf',
87                       value_type => 'string',
88                   },
89               },
90
91       If the configuration is loaded with:
92
93        $root->load("baz:one=un baz:two=deux")
94
95       Then the written YAML file does not show "baz":
96
97        ---
98        one: un
99        two: deux
100
101       Likewise, a YAML file for a class with a single list "baz" element
102       would be written with:
103
104        ---
105        - un
106        - deux
107

YAML class

109       As of v2.129, this backend uses YAML::XS 0.69 or later.
110
111       For security reason, loading a Perl blessed object is disabled.
112
113       Value of type boolean are written as boolean values in YAML files.
114

backend parameter

116   yaml_class
117       This parameter is ignored as of version 2.129.
118

CONSTRUCTOR

120   new
121       Parameters: "( node => $node_obj, name => 'yaml' )"
122
123       Inherited from Config::Model::Backend::Any. The constructor is called
124       by Config::Model::BackendMgr.
125
126   read
127       Read YAML file and load into $node_obj tree.
128
129       When a file is read, "read" returns 1.
130
131   write
132       Write YAML File using $node_obj data.
133
134       "write" returns 1.
135

AUTHOR

137       Dominique Dumont, (ddumont at cpan dot org)
138

SEE ALSO

140       Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,
141       YAML::XS
142

AUTHOR

144       Dominique Dumont
145
147       This software is Copyright (c) 2018 by Dominique Dumont.
148
149       This is free software, licensed under:
150
151         The GNU Lesser General Public License, Version 2.1, February 1999
152

SUPPORT

154   Websites
155       The following websites have more information about this module, and may
156       be of help to you. As always, in addition to those websites please use
157       your favorite search engine to discover more resources.
158
159       •   CPANTS
160
161           The CPANTS is a website that analyzes the Kwalitee ( code metrics )
162           of a distribution.
163
164           <http://cpants.cpanauthors.org/dist/Config-Model-Backend-Yaml>
165
166       •   CPAN Testers
167
168           The CPAN Testers is a network of smoke testers who run automated
169           tests on uploaded CPAN distributions.
170
171           <http://www.cpantesters.org/distro/C/Config-Model-Backend-Yaml>
172
173       •   CPAN Testers Matrix
174
175           The CPAN Testers Matrix is a website that provides a visual
176           overview of the test results for a distribution on various
177           Perls/platforms.
178
179           <http://matrix.cpantesters.org/?dist=Config-Model-Backend-Yaml>
180
181       •   CPAN Testers Dependencies
182
183           The CPAN Testers Dependencies is a website that shows a chart of
184           the test results of all dependencies for a distribution.
185
186           <http://deps.cpantesters.org/?module=Config::Model::Backend::Yaml>
187
188   Bugs / Feature Requests
189       Please report any bugs or feature requests by email to "ddumont at
190       cpan.org", or through the web interface at
191       <https://github.com/dod38fr/config-model-backend-yaml/issues>. You will
192       be automatically notified of any progress on the request by the system.
193
194   Source Code
195       The code is open to the world, and available for you to hack on. Please
196       feel free to browse it and play with it, or whatever. If you want to
197       contribute patches, please send me a diff or prod me to pull from your
198       repository :)
199
200       <http://github.com/dod38fr/config-model-backend-yaml>
201
202         git clone git://github.com/dod38fr/config-model-backend-yaml.git
203
204
205
206perl v5.34.0                      2022-01-21   Config::Model::Backend::Yaml(3)
Impressum