File: Master.pl

package info (click to toggle)
libconfig-model-tkui-perl 1.381-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 484 kB
  • sloc: perl: 3,685; makefile: 19
file content (442 lines) | stat: -rw-r--r-- 14,794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# -*- cperl -*-
use utf8;
use strict;
use warnings;

# this file is used by test script

return [
    [
        name    => 'SubSlave2',
        gist => 'subslave2 with aa2:{aa2}',
        element => [
            [qw/aa2 ab2 ac2 ad2 Z/] => {
                type       => 'leaf',
                value_type => 'string'
            }
        ]
    ],

    [
        name    => 'SubSlave',
        gist => 'subslave with aa:{aa}',
        element => [
            [qw/aa ab ac ad/] => {
                type       => 'leaf',
                value_type => 'uniline'
            },
            sub_slave => {
                type              => 'node',
                config_class_name => 'SubSlave2',
            }
        ]
    ],

    [
        name    => 'X_base_class2',
        gist => 'x_base_class2 with X:{X}',
        element => [
            X => {
                type       => 'leaf',
                value_type => 'enum',
                choice     => [qw/Av Bv Cv/]
            },
        ],
        class_description => 'rather dummy class to check include feature',
    ],

    [
        name    => 'X_base_class',
        gist => 'x_base_class with X:{X}',
        include => 'X_base_class2',
    ],

    [
        name    => 'SlaveZ',
        gist => 'SlaveZ Z:{Z} DX:{DX}',
        element => [
            [qw/Z/] => {
                type       => 'leaf',
                value_type => 'enum',
                choice     => [qw/Av Bv Cv/]
            },
            [qw/DX/] => {
                type       => 'leaf',
                value_type => 'enum',
                default    => 'Dv',
                choice     => [qw/Av Bv Cv Dv/]
            },
        ],
        include       => 'X_base_class',
        include_after => 'Z',
    ],

    [
        name    => 'SlaveY',
        gist => 'slaveY with Y:{Y}',
        element => [
            std_id => {
                type       => 'hash',
                index_type => 'string',
                cargo      => {
                    type              => 'node',
                    config_class_name => 'SlaveZ'
                },
            },
            sub_slave => {
                type              => 'node',
                config_class_name => 'SubSlave',
            },
            [qw/a_string a_long_string another_string/] => {
                type       => 'leaf',
                mandatory  => 1,
                value_type => 'string'
            },
            warp2 => {
                type              => 'warped_node',
                config_class_name => 'SubSlave',
                morph             => 1,
                warp => {
                    follow            => '! tree_macro',
                    rules             => [
                        mXY => { config_class_name => 'SubSlave2' },
                        XZ  => { config_class_name => 'SubSlave2' }
                    ]
                },
            },
            Y => {
                type       => 'leaf',
                value_type => 'enum',
                choice     => [qw/Av Bv Cv/]
            }, 
        ],
        include => 'X_base_class',
    ],

    [
        name              => 'Master',
        class_description => "

=head1 coucou

Master description . Let's go for a very long description with utf8 chars: ßéè.

Big class to do:

=over 

=item * 

shiny

=item *

beautiful

=back

things.
",
        level        => [ [qw/lista hash_a tree_macro int_v/] => 'important' ],
        rw_config => {
            backend     => 'cds_file',
            config_dir  => '/foo',
            file        => 'a_test.cds',
            auto_create => 1
        },
        gist => 'M tree_macro:{tree_macro}',
        accept => [
            'foo.*' => { type => 'leaf', value_type => 'uniline'}
        ],
        element => [
            tree_macro => {
                type       => 'leaf',
                value_type => 'enum',
                choice     => [qw/XY XZ mXY/],
                help       => {
                    XY  => 'XY help',
                    XZ  => 'XZ help',
                    mXY => 'mXY help',
                }
            },
            pop_in_out => {
                type       => 'leaf',
                level => 'hidden',
                value_type => 'uniline',
                default    => 'yada yada',
                warp => {
                    follow            => '! tree_macro',
                    rules             => [
                        XZ => { level => 'normal' },
                    ],
                },
            },

            [qw/compute_av compute_bv/] => {
                type       => 'leaf',
                class      => 'Config::Model::Value',
                value_type => 'integer',
            },
            compute_int => {
                type       => 'leaf',
                class      => 'Config::Model::Value',
                value_type => 'integer',
                compute    => {
                    formula   => '$a + $b',
                    variables => { a => '- compute_av', b => '- compute_bv' }
                },
                min => -4,
                max => 4,
            },
            std_id => {
                type       => 'hash',
                index_type => 'string',
                cargo      => {
                    type              => 'node',
                    config_class_name => 'SlaveZ'
                },
            },
            [qw/lista listb/] => {
                type  => 'list',
                cargo => {
                    type       => 'leaf',
                    value_type => 'uniline'
                },
                summary => 'lista and listb are used to yada yada with utf8 chars: ßéè',
            },
            [qw/hash_a hash_b/] => {
                type       => 'hash',
                index_type => 'string',
                cargo      => {
                    type       => 'leaf',
                    value_type => 'uniline'
                },
            },
            ordered_hash => {
                type       => 'hash',
                index_type => 'string',
                ordered    => 1,
                cargo      => {
                    type       => 'leaf',
                    value_type => 'uniline'
                },
            },
            ordered_hash_of_mandatory => {
                type       => 'hash',
                index_type => 'string',
                ordered    => 1,
                cargo      => {
                    type       => 'leaf',
                    value_type => 'uniline',
                    mandatory  => 1,
                },
            },
            'ordered_hash_of_nodes' => {
                type       => 'hash',
                index_type => 'string',
                ordered    => 1,
                cargo      => {
                    type              => 'node',
                    config_class_name => 'SlaveZ'
                },
            },
            olist => {
                type  => 'list',
                cargo => {
                    type              => 'node',
                    config_class_name => 'SlaveZ',
                },
            },
            enum_list => {
                type  => 'list',
                cargo => {
                    type       => 'leaf',
                    value_type => 'enum',
                    choice     => [qw/A B C/],
                }
            },

            "list_with_warn_duplicates" => { 
                type => 'list', 
                duplicates => 'warn' , 
                cargo => { type => 'leaf', value_type => 'string' } 
            },
             "hash_with_warn_duplicates" => { 
                type => 'hash',
                index_type => 'string', 
                duplicates => 'warn' , 
                cargo => { type => 'leaf', value_type => 'string' } 
            },
           warp => {
                type              => 'warped_node',
                config_class_name => 'SlaveY',
                morph             => 1,
                warp => {
                    follow            => '! tree_macro',
                    rules             => [
                        #XY => { config_class_name => 'SlaveY'},
                        mXY => { config_class_name => 'SlaveY' },
                        XZ  => { config_class_name => 'SlaveZ' }
                    ]
                }
            },

            'slave_y' => {
                type              => 'node',
                config_class_name => 'SlaveY',
            },

            string_with_def => {
                type       => 'leaf',
                value_type => 'uniline',
                default    => 'yada yada'
            },
            a_uniline => {
                type       => 'leaf',
                value_type => 'uniline',
                default    => 'yada yada'
            },
            a_boolean => {
                type       => 'leaf',
                value_type => 'boolean',
            },
            yes_no_boolean => {
                type       => 'leaf',
                value_type => 'boolean',
                upstream_default => 'yes',
                write_as => [ 'no', 'yes' ],
            },
            [qw/a_string a_long_string another_string/] => {
                type       => 'leaf',
                value_type => 'string'
            },
            [qw/a_very_long_string/] => {
                type       => 'leaf',
                value_type => 'string',
                default => "    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of the
    License, or (at your option) any later version.
    On Debian GNU/Linux systems, the complete text of version 2.1 of the GNU
    Lesser General Public License can be found in `/usr/share/common-licenses/LGPL-2.1'"
            },
            [qw/a_mandatory_string another_mandatory_string/] => {
                type       => 'leaf',
                mandatory  => 1,
                value_type => 'string'
            },
            int_v => {
                type       => 'leaf',
                value_type => 'integer',
                default    => '10',
                min        => 5,
                max        => 15
            },
            upstream_default => {
                type             => 'leaf',
                value_type       => 'integer',
                upstream_default => '10',
            },
            my_plain_check_list => {
                type   => 'check_list',
                choice => [ 'AA' .. 'AE' ],
                help   => {
                    AA => 'AA help',
                    AC => 'AC help',
                    AE => 'AE help',
                },
                description =>
                  'my_plain_check_list nto so helpful description',
            },
            enum_with_help => {
                type   => 'leaf',
                value_type => 'enum' ,
                choice => [ 'AA' .. 'AE' ],
                help   => { map { ( $_ => "$_ help with utf8 ßé²") ;} ('AA' .. 'AE') },
                description =>
                  'my_plain_check_list not so helpful description',
            },
            enum_with_help_and_long_desc => {
                type   => 'leaf',
                value_type => 'enum' ,
                choice => [ 'AA' .. 'AE' ],
                help   => { map { ( $_ => "$_ help with utf8 ßé²") ;} ('AA' .. 'AE') } ,
                description =>
                  "my_plain_check_list not so helpful\n even if B<long> description 😁",
            },
            my_ref_check_list => {
                type     => 'check_list',
                refer_to => '- hash_a + ! hash_b',
            },
            'ordered_checklist' => {
                type    => 'check_list',
                choice  => [ 'A' .. 'Z' ],
                ordered => 1,
                help    => { A => 'A help', E => 'E help' },
                summary => 'will checklist be served ? ;-) ',
            },

            'check_list_with_upstream_default', => {
                # from OpenSsh Ssh model (KexAlgorithms)
                'choice' => [
                    'ecdh-sha2-nistp256',
                    'ecdh-sha2-nistp384',
                    'ecdh-sha2-nistp521',
                    'diffie-hellman-group-exchange-sha256',
                    'diffie-hellman-group-exchange-sha1',
                    'diffie-hellman-group14-sha1',
                    'diffie-hellman-group1-sha1'
                ],
                'description' => 'Specifies the available KEX (Key Exchange) algorithms.',
                'type' => 'check_list',
                'upstream_default_list' => [
                    'diffie-hellman-group-exchange-sha1',
                    'diffie-hellman-group-exchange-sha256',
                    'diffie-hellman-group1-sha1',
                    'diffie-hellman-group14-sha1',
                    'ecdh-sha2-nistp256',
                    'ecdh-sha2-nistp384',
                    'ecdh-sha2-nistp521'
                ]
            },
            my_reference => {
                type       => 'leaf',
                value_type => 'reference',
                refer_to   => '- hash_a + ! hash_b',
                summary    => 'justify a long help ;-) ',
            },

            warn_unless => {
                type       => 'leaf',
                value_type => 'string',
                warn_unless_match =>
                  { foo => { msg => '', fix => '$_ = "foo".$_;' } },
            },
            always_warn => {
                type       => 'leaf',
                value_type => 'string',
                warn       => 'Always warn whenever used',
            },
            hash_with_warn_unless_key_match => {
                type       => 'hash',
                index_type => 'string',
                cargo      => { type => 'leaf', value_type => 'string' },
                warn_unless_key_match => 'foo',
            },

        ],
        description => [
            tree_macro    => 'controls behavior of other elements',
            a_long_string => "long string with \\n in it and with utf8 chars: ßéè",
            my_reference  => "very long help:\n"
              . "Config::Model enables a project developer to provide an interactive configuration editor to his users. For this he must:
- describe the structure and constraint of his project's configuration
- if the configuration data is not stored in INI file or in Perl data
  file, he must provide some code to read and write configuration from
  configuration files.
"
        ]
    ],
];

# do not put 1; at the end or Model-> load will not work