blib/lib/Config/Model/models/Itself/Class.pl

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 26 / 26 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Config/Model/models/Itself/CargoElement.pl ↑ Summary blib/lib/Config/Model/models/Itself/CommonElement.pl »
1 1 ▶#
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶# This file is part of Config-Model-Itself
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 #
4 # This software is Copyright (c) 2007-2026 by Dominique Dumont.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 # Copyright (c) 2007-2015 Dominique Dumont.
11 #
12 # This file is part of Config-Model-Itself.
13 #
14 # Config-Model-Itself is free software; you can redistribute it
15 # and/or modify it under the terms of the GNU Lesser Public License
16 # as published by the Free Software Foundation; either version 2.1
17 # of the License, or (at your option) any later version.
18 #
19 # Config-Model-Itself is distributed in the hope that it will be
20 # useful, but WITHOUT ANY WARRANTY; without even the implied
21 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 # See the GNU Lesser Public License for more details.
23 #
24 # You should have received a copy of the GNU Lesser Public License
25 # along with Config-Model-Itself; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27  
28 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
29 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 return [
32 [
33 7 name => "Itself::Class",
34 author => 'Dominique Dumont',
35 copyright => '2007-2011 Dominique Dumont.',
36 license => 'LGPL-2',
37  
38 class_description =>
39 "Configuration class. This class represents a node of a configuration tree.",
40  
41 'element' => [
42  
43 [qw/class_description license gist/] => {
44 type => 'leaf',
45 value_type => 'string',
46 },
47  
48 [qw/author copyright/] => {
49 type => 'list',
50 cargo => {
51 type => 'leaf',
52 value_type => 'uniline',
53 }
54 },
55  
56 'class' => {
57 type => 'leaf',
58 value_type => 'uniline',
59 summary => "Override implementation of configuration node",
60 description =>
61 "Perl class name used to override the default implementation of a configuration node. "
62 ."This Perl class must inherit L<Config::Model::Node>. Use with care.",
63 assert => {
64 "1_load_class" => {
65 code => 'return 1 unless defined $_;'
66 .'return Mouse::Util::load_class($_);',
67 msg => 'Error while loading $_ class ',
68 },
69 "2_class_inherit" => {
70 code => 'not defined $_ or $_->isa("Config::Model::Node")',
71 msg => 'class $_ must inherit Config::Model::Node',
72 }
73 },
74  
75 },
76  
77 'element' => {
78 type => 'hash',
79 level => 'important',
80 ordered => 1,
81 index_type => 'string',
82 cargo => {
83 type => 'node',
84 config_class_name => 'Itself::Element',
85 },
86 },
87  
88 [qw/include include_backend/] => {
89 type => 'list',
90 cargo => {
91 type => 'leaf',
92 value_type => 'reference',
93 refer_to => '! class',
94 }
95 },
96  
97 'include_after' => {
98 type => 'leaf',
99 value_type => 'reference',
100 refer_to => '- element',
101 },
102  
103 generated_by => {
104 type => 'leaf',
105 value_type => 'uniline',
106 },
107  
108 rw_config => {
109 type => 'node',
110 config_class_name => 'Itself::ConfigReadWrite',
111 },
112  
113 'accept' => {
114 type => 'hash',
115 index_type => 'string',
116 ordered => 1,
117 cargo => {
118 type => 'node',
119 config_class_name => 'Itself::ConfigAccept',
120 },
121 },
122 ],
123 'description' => [
124 element => "Specify the elements names of this configuration class.",
125 gist => 'String used to construct a summary of the content of a node. This '
126 .'parameter is used by user interface to show users the gist of the '
127 .'content of this node. This parameter has no other effect. This string '
128 .'may contain element values in the form "C<{foo} or {bar}>". When '
129 .'constructing the gist, C<{foo}> is replaced by the value of element '
130 .'C<foo>. Likewise for C<{bar}>.',
131 include => "Include the element description of another class into this class.",
132 include_after => "insert the included elements after a specific element. "
133 . "By default, included elements are placed before all other elements.",
134 include_backend => "Include the read/write specification of another class into this class.",
135 class_description => "Explain the purpose of this configuration class. This description is re-used to generate the documentation of your configuration class. You can use pod markup to format your description. See L<perlpod> for details.",
136 rw_config => "Specify the backend used to read and write configuration data. See L<Config::Model::BackendMgr> for details",
137 generated_by => "When set, this class was generated by some program. You should not edit "
138 ."this class as your modifications may be clobbered later on when the class is regenerated.",
139 accept => "Specifies names of the elements this configuration class accepts as valid. "
140 ],
141 ],
142  
143 [
144 name => 'Itself::ConfigReadWrite::DefaultLayer',
145  
146 'element' => [
147 'config_dir' => {
148 type => 'leaf',
149 value_type => 'uniline',
150 level => 'normal',
151 },
152  
153 os_config_dir => {
154 type => 'hash',
155 index_type => 'string',
156 cargo => {
157 type => 'leaf',
158 value_type => 'uniline',
159 },
160 summary => 'configuration file directory for specific OS',
161 description => 'Specify and alternate location of a configuration directory depending '
162 .q!on the OS (as returned by C<$^O> or C<$Config{'osname'}>, see L<perlport/PLATFORMS>) !
163 .q!Common values for C<$^O> are 'linux', 'MSWin32', 'darwin'!
164 },
165 'file' => {
166 type => 'leaf',
167 value_type => 'uniline',
168 level => 'normal',
169 summary => 'target configuration file name',
170 description => 'specify the configuration file name. This parameter may '
171 .'not be applicable depending on your application. It may also be '
172 .'hardcoded in a custom backend. If not specified, the instance name '
173 .'is used as base name for your configuration file. The configuration file name'
174 .'can be specified with &index() or &element function. See '
175 .'L<backend specifications|http://search.cpan.org/dist/Config-Model/lib/Config/Model/BackendMgr.pm#Backend_specification> '
176 .'and L<Config::Model::Role::ComputeFunction>.'
177 },
178 ]
179 ],
180  
181 [
182 name => "Itself::ConfigReadWrite",
183 include => "Itself::ConfigReadWrite::DefaultLayer",
184 include_after => 'backend',
185  
186 'element' => [
187  
188 'backend' => {
189 type => 'leaf',
190 class => 'Config::Model::Itself::BackendDetector',
191 value_type => 'enum',
192 choice => [qw/cds_file perl_file custom/],
193 warn_if_match => {
194 '^custom$' => {
195 msg => "custom backend are deprecated"
196 }
197 },
198 replace => {
199 perl => 'perl_file',
200 ini => 'IniFile',
201 ini_file => 'IniFile',
202 cds => 'cds_file',
203 },
204 description => 'specifies the backend to store permanently configuration data.',
205 help => {
206 cds_file => "file with config data string. This is Config::Model own serialisation format, designed to be compact and readable. Configuration filename is made with instance name",
207 IniFile =>
208 "Ini file format. Beware that the structure of your model must match the limitations of the INI file format, i.e only a 2 levels hierarchy. Configuration filename is made with instance name",
209 perl_file =>
210 "file with a perl data structure. Configuration filename is made with instance name",
211 custom => "deprecated",
212 }
213 },
214  
215 'function' => {
216 type => 'leaf',
217 value_type => 'uniline',
218 status => 'deprecated',
219 level => 'hidden',
220 warp => {
221 follow => '- backend',
222 rules => [
223 custom => {
224 level => 'normal',
225 upstream_default => 'read',
226 }
227 ],
228 }
229 },
230  
231 'auto_create' => {
232 type => 'leaf',
233 value_type => 'boolean',
234 level => 'normal',
235 upstream_default => 0,
236 summary => 'Creates configuration files as needed',
237 },
238  
239 yaml_class => {
240 type => 'leaf',
241 value_type => 'uniline',
242 level => 'hidden',
243 description => 'Specify the YAML class that is used to load and dump YAML files.'
244 .' Defaults to L<YAML::Tiny>.'
245 .' See L<yaml_class doc|Config::Model::Backend::Yaml/yaml_class> for details on '
246 .' why another YAML class can suit your configuration file needs.',
247 upstream_default => 'YAML::Tiny',
248 warp => {
249 follow => '- backend',
250 rules => [ Yaml => { level => 'normal', } ],
251 }
252 },
253  
254 file_mode => {
255 type => 'leaf',
256 value_type => 'uniline',
257 level => 'normal',
258 summary => 'configuration file mode',
259 description => 'specify the configuration file mode. C<file_mode> parameter can be used to set the '
260 . 'mode of the written file. C<file_mode> value can be in any form supported by L<Path::Tiny/chmod>.'
261 },
262  
263 default_layer => {
264 type => 'node',
265 config_class_name => 'Itself::ConfigReadWrite::DefaultLayer',
266 summary => q!How to find default values in a global config file!,
267 description => q!Specifies where to find a global configuration file that !
268 .q!specifies default values. For instance, this is used by OpenSSH to !
269 .q!specify a global configuration file (C</etc/ssh/ssh_config>) that is !
270 .q!overridden by user's file!,
271 },
272  
273 'class' => {
274 type => 'leaf',
275 value_type => 'uniline',
276 level => 'hidden',
277 warp => {
278 follow => '- backend',
279 rules => [
280 custom => {
281 level => 'normal',
282 mandatory => 1,
283 }
284 ],
285 }
286 },
287  
288 'store_class_in_hash' => {
289 type => 'leaf',
290 value_type => 'uniline',
291 level => 'hidden',
292 description => 'Specify element hash name that contains all INI classes. '
293 .'See L<Config::Model::Backend::IniFile/"Arbitrary class name">',
294 warp => {
295 follow => '- backend',
296 rules => [ IniFile => { level => 'normal', } ],
297 }
298 },
299  
300 'section_map' => {
301 type => 'hash',
302 level => 'hidden',
303 index_type => 'string',
304 description => 'Specify element name that contains one INI class. E.g. to store '
305 .'INI class [foo] in element Foo, specify { foo => "Foo" } ',
306 warp => {
307 follow => '- backend',
308 rules => [ IniFile => { level => 'normal', } ],
309 },
310 cargo => {
311 type => 'leaf',
312 value_type => 'uniline',
313 },
314 },
315  
316 ['split_list_value','split_check_list_value'] => {
317 type => 'leaf',
318 value_type => 'uniline',
319 level => 'hidden',
320 description => 'Regexp to split the value read from ini file. Usually "\s+" or "[,\s]"',
321 warp => {
322 follow => '- backend',
323 rules => [ IniFile => { level => 'normal', } ],
324 }
325 },
326  
327 assign_char => {
328 type => 'leaf',
329 value_type => 'uniline',
330 level => 'hidden',
331 description => 'Character used to assign value in INI file. Default is C<=>. '
332 .'See L<details|Config::Model::Backend::IniFile/"Handle key value files">',
333 upstream_default => '#',
334 warp => {
335 follow => '- backend',
336 rules => [ IniFile => { level => 'normal', } ],
337 }
338 },
339  
340 assign_with => {
341 type => 'leaf',
342 value_type => 'uniline',
343 level => 'hidden',
344 description => 'String used write assignment in INI file. Default is "C< = >". '
345 .'See L<details|Config::Model::Backend::IniFile/"Handle key value files">',
346 upstream_default => '#',
347 warp => {
348 follow => '- backend',
349 rules => [ IniFile => { level => 'normal', } ],
350 }
351 },
352  
353 ['join_list_value', 'join_check_list_value'] => {
354 type => 'leaf',
355 value_type => 'uniline',
356 level => 'hidden',
357 warp => {
358 follow => '- backend',
359 rules => [ IniFile => { level => 'normal', } ],
360 }
361 },
362  
363 'write_boolean_as' => {
364 type => 'list',
365 description => 'Specify how to write a boolean value in config file. Suggested values are '
366 . '"no","yes". ',
367 max_index => 1,
368 cargo => {
369 type => 'leaf',
370 value_type => 'uniline',
371 },
372 },
373  
374 force_lc_section => {
375 type => 'leaf',
376 value_type => 'boolean',
377 level => 'hidden',
378 upstream_default => 0,
379 description => "force section to be lowercase",
380 warp => {
381 follow => '- backend',
382 rules => [ IniFile => { level => 'normal', } ],
383 }
384 },
385 force_lc_key => {
386 type => 'leaf',
387 value_type => 'boolean',
388 level => 'hidden',
389 upstream_default => 0,
390 description => "force key names to be lowercase",
391 warp => {
392 follow => '- backend',
393 rules => [ IniFile => { level => 'normal', } ],
394 }
395 },
396 force_lc_value => {
397 type => 'leaf',
398 value_type => 'boolean',
399 level => 'hidden',
400 upstream_default => 0,
401 description => "force values to be lowercase",
402 warp => {
403 follow => '- backend',
404 rules => [ IniFile => { level => 'normal', } ],
405 }
406 },
407  
408 'full_dump' => {
409 type => 'leaf',
410 value_type => 'boolean',
411 level => 'hidden',
412 description => 'Also dump default values in the data structure. Useful if the dumped configuration data will be used by the application. (default is yes)',
413 upstream_default => '1',
414 warp => {
415 follow => { backend => '- backend' },
416 rules => [ '$backend =~ /yaml|perl/i' => { level => 'normal', } ],
417 }
418 },
419  
420 'comment_delimiter' => {
421 type => 'leaf',
422 value_type => 'uniline',
423 level => 'hidden',
424 description => 'list of characters that start a comment. When more that one character'
425 .' is used. the first one is used to write back comment. For instance,'
426 .' value "#;" indicate that a comments can start with "#" or ";" and that all comments'
427 .' are written back with "#".',
428 upstream_default => '#',
429 warp => {
430 follow => '- backend',
431 rules => [ IniFile => { level => 'normal', } ],
432 }
433 },
434  
435 quote_value => {
436 type => 'leaf',
437 value_type => 'enum',
438 choice => ['shell_style'],
439 level => 'hidden',
440 description => 'Specify how to handle quoted values. By default, quoted values '
441 .'are left as is. With C<shell_style>, value are parsed and unquoted like in a shell. '
442 .'Values containing a space are written back with double quotes.',
443 warp => {
444 follow => '- backend',
445 rules => [ IniFile => { level => 'normal', } ],
446 }
447 },
448  
449 'auto_delete' => {
450 type => 'leaf',
451 value_type => 'boolean',
452 level => 'normal',
453 upstream_default => 0,
454 summary => 'Delete empty configuration file',
455 description => 'Delete configuration files when no information is left in there.'
456 . ' This may happen when data is removed by user. This is mostly useful when the '
457 . ' configuration of an application is made of several files.',
458 },
459  
460 ],
461 description => [
462 join_list_value => 'string to join list values before writing the entry in ini file. Usually " " or ", "',
463 join_check_list_value => 'string to join checked items names before writing the entry in the ini file. Usually " " or ", "',
464 ],
465  
466 ],
467  
468 [
469 name => 'Itself::ConfigAccept',
470  
471 include => "Itself::Element",
472 include_after => 'accept_after',
473 'element' => [
474 'pattern' => {
475 type => 'leaf',
476 value_type => 'uniline',
477 # status => 'mandatory',
478 description => "A regular expression that is tested against
479 candidate parameters. When the parameter matches the regular expression,
480 a new parameter is created in the model using the properties defined along C<pattern>.
481 Note that the regexp must match the whole name
482 of the potential parameter. I.e. the specified regexp is eval\'ed
483 with a leading C<^> and a trailing C<\$>."
484  
485 },
486 'accept_after' => {
487 type => 'leaf',
488 value_type => 'reference' ,
489 refer_to => '- - element' ,
490 description => 'specify where to insert accepted element. This does'
491 . ' not change the behavior and helps generating more consistent '
492 . ' user interfaces'
493 }
494  
495 ],
496 ],
497  
498 ];
« blib/lib/Config/Model/models/Itself/CargoElement.pl ↑ Summary blib/lib/Config/Model/models/Itself/CommonElement.pl »