File: WarpableElement.pl

package info (click to toggle)
libconfig-model-itself-perl 2.025-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 468 kB
  • sloc: perl: 3,507; makefile: 12
file content (162 lines) | stat: -rw-r--r-- 7,020 bytes parent folder | download | duplicates (2)
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
#    Copyright (c) 2007-2011 Dominique Dumont.
#
#    This file is part of Config-Model-Itself.
#
#    Config-Model-Itself is free software; you can redistribute it
#    and/or modify it under the terms of the GNU Lesser Public License
#    as published by the Free Software Foundation; either version 2.1
#    of the License, or (at your option) any later version.
#
#    Config-Model-Itself is distributed in the hope that it will be
#    useful, but WITHOUT ANY WARRANTY; without even the implied
#    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#    See the GNU Lesser Public License for more details.
#
#    You should have received a copy of the GNU Lesser Public License
#    along with Config-Model-Itself; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA

use strict;
use warnings;

return [
    [
        name => "Itself::WarpableElement",

        include => 'Itself::CommonElement',

        'element' => [

            [
                qw/allow_keys_from allow_keys_matching follow_keys_from
                  warn_if_key_match warn_unless_key_match/
            ] => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'uniline',
                warp       => {
                    follow  => { 't'            => '?type' },
                    'rules' => [ '$t eq "hash"' => { level => 'normal', } ]
                }
            },

            [qw/ordered/] => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'boolean',
                warp       => {
                    follow  => { 't' => '?type' },
                    'rules' => [
                        '$t eq "hash" or $t eq "check_list"' =>
                          { level => 'normal', }
                    ]
                }
            },

            [qw/default_keys auto_create_keys allow_keys/] => {
                type       => 'list',
                level      => 'hidden',
                cargo      => { type => 'leaf', value_type => 'string' },
                warp       => {
                    follow  => { 't'            => '?type' },
                    'rules' => [ '$t eq "hash"' => { level => 'normal', } ]
                }
            },

            [qw/auto_create_ids/] => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'string',
                warp       => {
                    follow  => { 't'            => '?type' },
                    'rules' => [ '$t eq "list"' => { level => 'normal', } ]
                }
            },

            [qw/default_with_init/] => {
                type       => 'hash',
                level      => 'hidden',
                index_type => 'string',
                cargo      => { type => 'leaf', value_type => 'string' },
                warp       => {
                    follow  => { 't'            => '?type' },
                    'rules' => [ '$t eq "hash" or $t eq "list"' => { level => 'normal', } ]
                }
            },

            'max_nb' => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'integer',
                warp       => {
                    follow  => { 'type'            => '?type', },
                    'rules' => [ '$type eq "hash"' => { level => 'normal', } ]
                }
            },

            'replace' => {
                type       => 'hash',
                index_type => 'string',
                level      => 'hidden',
                warp       => {
                    follow  => { 't' => '?type' },
                    'rules' => [
                        '$t eq "leaf" or $t eq "check_list"' =>
                          { level => 'normal', }
                    ]
                },

                # TBD this could be a reference if we restrict replace to
                # enum value...
                cargo => { type => 'leaf', value_type => 'string' },
            },

            [ qw/duplicates/ ] => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'enum',
                choice     => [qw/allow suppress warn forbid/],
                upstream_default => 'allow',
                warp       => {
                    follow  => { 't'                            => '?type' },
                    'rules' => [ '$t eq "hash" or $t eq "list"' => { level => 'normal', } ]
                }
            },

            help => {
                type       => 'hash',
                index_type => 'string',
                level      => 'hidden',
                warp       => {
                    follow  => { 't' => '?type' },
                    'rules' => [
                        '$t eq "leaf" or $t eq "check_list"' =>
                          { level => 'normal', }
                    ]
                },

                # TBD this could be a reference if we restrict replace to
                # enum value...
                cargo => { type => 'leaf', value_type => 'string' },
            },
        ],

        'description' => [
            follow_keys_from => 'this hash contains the same keys as the hash pointed by the path string',
            allow_keys_from => 'this hash allows keys from the keys of the hash pointed by the path string',
            ordered => 'keep track of the order of the elements of this hash',
            default_keys => 'default keys hashes.',
            auto_create_keys => 'always create a set of keys specified in this list',
            auto_create_ids => 'always create the number of id specified in this integer',
            allow_keys => 'specify a set of allowed keys',
            allow_keys_matching => 'Keys must match the specified regular expression.',
            default_with_init => 'specify a set of keys to create and initialization on some elements . E.g. \' foo => "X=Av Y=Bv", bar => "Y=Av Z=Cz"\' ',
            help => 'Specify help string applicable to values. The keys are regexp matched to the beginning of the value. See C<help> parameter of L<Config::Model::Value/DESCRIPTION> for more possibilities',
            replace => 'Used for enum to substitute one value with another. This parameter must be used to enable user to upgrade a configuration with obsolete values. The old value is the key of the hash, the new one is the value of the hash',
            warn_if_key_match => 'Warn user if a key is created matching this regular expression',
            warn_unless_key_match => 'Warn user if a key is created not matching this regular expression',
            duplicates => 'Specify the policy regarding duplicated values stored in the list or as hash values (valid only when cargo type is "leaf"). The policy can be "allow" (default), "suppress", "warn" (which offers the possibility to apply a fix), "forbid".',
        ],
    ],

];