blib/lib/Config/Model/models/Itself/NonWarpableElement.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/Model.pl ↑ Summary blib/lib/Config/Model/models/Itself/WarpOnlyElement.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-2011 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 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
29 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 return [
32 [
33 6 name => 'Itself::NonWarpableElement',
34  
35 # warp often depend on this one, so list it first
36 'element' => [
37 'value_type' => {
38 type => 'leaf',
39 level => 'hidden',
40 value_type => 'enum',
41 choice => [
42 qw/boolean enum integer reference
43 number uniline string file dir/
44 ],
45 'warp' => {
46 follow => { 't' => '- type' },
47 'rules' => [{
48 when => '$t eq "leaf"',
49 apply => {
50 level => 'normal',
51 mandatory => 1,
52 }
53 }]
54 },
55 help => {
56 integer => 'positive or negative integer',
57 uniline => 'string with no embedded newline',
58 }
59 },
60  
61 'class' => {
62 type => 'leaf',
63 level => 'hidden',
64 value_type => 'uniline',
65 summary => "Override implementation of element",
66 description =>
67 "Perl class name used to override the implementation of the configuration element. "
68 ."This override Perl class must inherit a Config::Model class that matches the element type, "
69 ."i.e. Config::Model::Value, Config::Model::HashId or Config::Model::ListId. "
70 ."Use with care.",
71 'warp' => {
72 follow => { 't' => '- type' },
73 'rules' => [{
74 when => '$t and $t !~ /node/',
75 apply => { level => 'normal', }
76 }]
77 }
78 },
79  
80 'morph' => {
81 type => 'leaf',
82 level => 'hidden',
83 value_type => 'boolean',
84 'warp' => {
85 follow => { type => '- type' },
86 'rules' => [{
87 when => '$type eq "warped_node"',
88 apply => {
89 level => 'normal',
90 upstream_default => 0,
91 },
92 }]
93 },
94 description =>
95 "When set, a recurse copy of the value from the old object "
96 . "to the new object is attempted. Old values are dropped when "
97 ." a copy is not possible (usually because of mismatching types)."
98 },
99  
100 # end warp elements for warped_node
101  
102 # leaf element
103  
104 'refer_to' => {
105 type => 'leaf',
106 level => 'hidden',
107 value_type => 'uniline',
108 warp => {
109 follow => {
110 t => '- type',
111 vt => '- value_type',
112 },
113 'rules' => [{
114 when => '$t eq "check_list" or $vt eq "reference"',
115 apply => { level => 'important', },
116 }]
117 },
118 description =>
119 "points to an array or hash element in the configuration "
120 . "tree using L<grab syntax|Config::Model::Role::Grab>. "
121 . "The available choice of this "
122 . "reference value (or check list)is made from the available "
123 . "keys of the pointed hash element or the values of the pointed array element.",
124 },
125  
126 'computed_refer_to' => {
127 type => 'warped_node',
128 level => 'hidden',
129 warp => {
130 follow => {
131 t => '- type',
132 vt => '- value_type',
133 },
134 'rules' => [{
135 when => '$t eq "check_list" or $vt eq "reference"',
136 apply => {
137 level => 'normal',
138 config_class_name => 'Itself::ComputedValue',
139 },
140 }],
141 },
142 description =>
143 "points to an array or hash element in the configuration "
144 . "tree using a path computed with value from several other "
145 . "elements in the configuration tree. The available choice "
146 . "of this reference value (or check list) is made from the "
147 . "available keys of the pointed hash element or the values "
148 . "of the pointed array element. The keys of several hashes (or lists) "
149 . "can be combined by using the '+' operator in the formula. "
150 . q(For instance, '! host:$a lan + ! host:foobar lan'. See )
151 . "L<Config::Model::IdElementReference> for more details."
152 },
153  
154 'replace_follow' => {
155 type => 'leaf',
156 level => 'hidden',
157 value_type => 'uniline',
158 warp => {
159 follow => { t => '- type' },
160 'rules' => [{
161 when => '$t eq "leaf"',
162 apply => { level => 'important', },
163 }]
164 },
165 description =>
166 "Path specifying a hash of value element in the configuration "
167 . "tree. The hash if used in a way similar to the replace "
168 . "parameter. In this case, the replacement is not coded "
169 . "in the model but specified by the configuration.",
170 },
171  
172 'compute' => {
173 type => 'warped_node',
174 level => 'hidden',
175  
176 warp => {
177 follow => { t => '- type', },
178 'rules' => [{
179 when => '$t eq "leaf"',
180 apply => {
181 level => 'normal',
182 config_class_name => 'Itself::ComputedValue',
183 },
184 }],
185 },
186 description =>
187 "compute the default value according to a formula and value "
188 . "from other elements in the configuration tree.",
189 },
190  
191 'migrate_from' => {
192 type => 'warped_node',
193 level => 'hidden',
194  
195 warp => {
196 follow => { t => '- type', },
197 'rules' => [{
198 when => '$t eq "leaf"',
199 apply => {
200 level => 'normal',
201 config_class_name => 'Itself::MigratedValue',
202 },
203 }],
204 },
205 description =>
206 "Specify an upgrade path from an old value and compute "
207 . "the value to store in the new element.",
208 },
209  
210 'write_as' => {
211 type => 'list',
212 level => 'hidden',
213 max_index => 1,
214  
215 warp => {
216 follow => { t => '- type', vt => '- value_type'},
217 rules => [{
218 when => '$t eq "leaf" and $vt eq "boolean"',
219 apply => { level => 'normal', },
220 }]
221 },
222 cargo => {
223 type => 'leaf',
224 value_type => 'uniline',
225 },
226 description =>
227 "Specify how to write a boolean value. Example 'no' 'yes'.",
228 },
229  
230 # hash or list element
231 migrate_values_from => {
232 type => 'leaf',
233 level => 'hidden',
234 value_type => 'uniline',
235 warp => {
236 follow => { 't' => '?type' },
237 'rules' => [{
238 when => '$t eq "hash" or $t eq "list"',
239 apply => { level => 'normal', }
240 }]
241 } ,
242 description => 'Specifies that the values of the hash or list are copied '
243 . 'from another hash or list in the configuration tree once configuration '
244 . 'data are loaded.',
245 },
246  
247 # hash element
248 migrate_keys_from => {
249 type => 'leaf',
250 level => 'hidden',
251 value_type => 'uniline',
252 warp => {
253 follow => { 't' => '?type' },
254 'rules' => [{
255 when => '$t eq "hash"',
256 apply => { level => 'normal', }
257 }]
258 },
259 description => 'Specifies that the keys of the hash are copied from another hash '
260 . 'in the configuration tree only when the hash is created.',
261 },
262  
263 write_empty_value => {
264 type => 'leaf',
265 level => 'hidden',
266 value_type => 'boolean',
267 upstream_default => 0,
268 warp => {
269 follow => { 't' => '?type' },
270 rules => [{
271 when => '$t eq "hash"',
272 apply => { level => 'normal', }
273 }]
274 },
275 description => 'By default, hash entries without data are not saved in configuration '
276 . 'files. Set this parameter to 1 if a key must be saved in the configuration '
277 . 'file even if the hash contains no value for that key.',
278 },
279 # list element
280  
281 ],
282 ],
283 ];
« blib/lib/Config/Model/models/Itself/Model.pl ↑ Summary blib/lib/Config/Model/models/Itself/WarpOnlyElement.pl »