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.133
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       ·   Search CPAN
160
161           The default CPAN search engine, useful to view POD in HTML format.
162
163           <http://search.cpan.org/dist/Config-Model-Backend-Yaml>
164
165       ·   AnnoCPAN
166
167           The AnnoCPAN is a website that allows community annotations of Perl
168           module documentation.
169
170           <http://annocpan.org/dist/Config-Model-Backend-Yaml>
171
172       ·   CPAN Ratings
173
174           The CPAN Ratings is a website that allows community ratings and
175           reviews of Perl modules.
176
177           <http://cpanratings.perl.org/d/Config-Model-Backend-Yaml>
178
179       ·   CPANTS
180
181           The CPANTS is a website that analyzes the Kwalitee ( code metrics )
182           of a distribution.
183
184           <http://cpants.cpanauthors.org/dist/Config-Model-Backend-Yaml>
185
186       ·   CPAN Testers
187
188           The CPAN Testers is a network of smoke testers who run automated
189           tests on uploaded CPAN distributions.
190
191           <http://www.cpantesters.org/distro/C/Config-Model-Backend-Yaml>
192
193       ·   CPAN Testers Matrix
194
195           The CPAN Testers Matrix is a website that provides a visual
196           overview of the test results for a distribution on various
197           Perls/platforms.
198
199           <http://matrix.cpantesters.org/?dist=Config-Model-Backend-Yaml>
200
201       ·   CPAN Testers Dependencies
202
203           The CPAN Testers Dependencies is a website that shows a chart of
204           the test results of all dependencies for a distribution.
205
206           <http://deps.cpantesters.org/?module=Config::Model::Backend::Yaml>
207
208   Bugs / Feature Requests
209       Please report any bugs or feature requests by email to "ddumont at
210       cpan.org", or through the web interface at
211       <https://github.com/dod38fr/config-model-backend-yaml/issues>. You will
212       be automatically notified of any progress on the request by the system.
213
214   Source Code
215       The code is open to the world, and available for you to hack on. Please
216       feel free to browse it and play with it, or whatever. If you want to
217       contribute patches, please send me a diff or prod me to pull from your
218       repository :)
219
220       <http://github.com/dod38fr/config-model-backend-yaml>
221
222         git clone git://github.com/dod38fr/config-model-backend-yaml.git
223
224
225
226perl v5.30.1                      2020-01-29   Config::Model::Backend::Yaml(3)
Impressum