Config-Model-Itself

 view release on metacpan or  search on metacpan

data/models/MasterModel.pl  view on Meta::CPAN

                status     => 'deprecated',
                description =>
                  'deprecated_p is replaced by new_from_deprecated',
            },

            'new_from_deprecated' => {
                type         => 'leaf',
                value_type   => 'enum',
                choice       => [qw/cds_file perl_file ini_file custom/],
                migrate_from => {
                    formula   => '$replace{$old}',
                    variables => { old => '- deprecated_p' },
                    replace   => {
                        perl => 'perl_file',
                        ini  => 'ini_file',
                        cds  => 'cds_file',
                    },
                },
            },
            'old_url' => {
                type       => 'leaf',
                value_type => 'uniline',
                status     => 'deprecated',
            },
            'host' => {
                type         => 'leaf',
                value_type   => 'uniline',
                migrate_from => {
                    formula   => '$old =~ m!http://([\w\.]+)!; $1 ;',
                    variables => { old => '- old_url' },
                    use_eval  => 1,
                },
            },
            'reference_stuff' => {
                type              => 'node',
                config_class_name => 'MasterModel::References',
            },
            match => {
                type       => 'leaf',

data/models/MasterModel.pl  view on Meta::CPAN

                        code => 'defined $_ and /\w/',
                        msg  => 'should not be empty',
                        fix  => '$_ = "foobar";'
                    }
                },
            },
            'Source' => {
                'value_type'   => 'string',
                'migrate_from' => {
                    'use_eval'  => '1',
                    'formula'   => '$old || $older ;',
                    undef_is    => "''",
                    'variables' => {
                        'older' => '- Original-Source-Location',
                        'old'   => '- Upstream-Source'
                    }
                },
                'type' => 'leaf',
            },
            [qw/Upstream-Source Original-Source-Location/] => {
                'value_type' => 'string',

lib/Config/Model/models/Itself/ComputedValue.pl  view on Meta::CPAN

return [
    [
        name => "Itself::ComputedValue",
        include => "Itself::MigratedValue" ,

        element => [
            allow_override => {
                type => 'leaf',
                value_type => 'boolean',
                compute => {
                    formula => '$upstream_knowns',
                    variables => {
                        upstream_knowns => '- use_as_upstream_default',
                    },
                    use_as_upstream_default => 1,
                },
                level => 'normal',
                description => "Allow user to override computed value"
                    .'For more details, see L<doc|Config::Model::ValueComputer.pm/"compute override"> ',,
            },

lib/Config/Model/models/Itself/ConfigAccept.pod  view on Meta::CPAN

=head2 morph

When set, a recurse copy of the value from the old object to the new object is attempted. Old values are dropped when  a copy is not possible (usually because of mismatching types). I< Optional. Type boolean.  > 

=head2 refer_to

points to an array or hash element in the configuration tree using L<grab syntax|Config::Model::Role::Grab>. The available choice of this reference value (or check list)is made from the available keys of the pointed hash element or the values of the ...

=head2 computed_refer_to

points to an array or hash element in the configuration tree using a path computed with value from several other elements in the configuration tree. The available choice of this reference value (or check list) is made from the available keys of the p...

=head2 replace_follow

Path specifying a hash of value element in the configuration tree. The hash if used in a way similar to the replace parameter. In this case, the replacement is not coded in the model but specified by the configuration. I< Optional. Type uniline.  > 

=head2 compute

compute the default value according to a formula and value from other elements in the configuration tree. I< Optional. Type warped_node.  > 

=head2 migrate_from

Specify an upgrade path from an old value and compute the value to store in the new element. I< Optional. Type warped_node.  > 

=head2 write_as

Specify how to write a boolean value. Example 'no' 'yes'. I< Optional. Type list of uniline.  > 

=head2 migrate_values_from

lib/Config/Model/models/Itself/Element.pod  view on Meta::CPAN

=head2 morph

When set, a recurse copy of the value from the old object to the new object is attempted. Old values are dropped when  a copy is not possible (usually because of mismatching types). I< Optional. Type boolean.  > 

=head2 refer_to

points to an array or hash element in the configuration tree using L<grab syntax|Config::Model::Role::Grab>. The available choice of this reference value (or check list)is made from the available keys of the pointed hash element or the values of the ...

=head2 computed_refer_to

points to an array or hash element in the configuration tree using a path computed with value from several other elements in the configuration tree. The available choice of this reference value (or check list) is made from the available keys of the p...

=head2 replace_follow

Path specifying a hash of value element in the configuration tree. The hash if used in a way similar to the replace parameter. In this case, the replacement is not coded in the model but specified by the configuration. I< Optional. Type uniline.  > 

=head2 compute

compute the default value according to a formula and value from other elements in the configuration tree. I< Optional. Type warped_node.  > 

=head2 migrate_from

Specify an upgrade path from an old value and compute the value to store in the new element. I< Optional. Type warped_node.  > 

=head2 write_as

Specify how to write a boolean value. Example 'no' 'yes'. I< Optional. Type list of uniline.  > 

=head2 migrate_values_from

lib/Config/Model/models/Itself/MigratedValue.pl  view on Meta::CPAN


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

        element => [
            variables => {
                type => 'hash',
                index_type => 'string' ,
                cargo => { type => 'leaf', value_type => 'uniline' } ,
                description => 'Specify where to find the variables using path notation. For the formula '
                    .'"$a + $b", you need to specify "a => \'- a_path\', b => \'! b_path\'. '
                    .'Functions like C<&index()> are allowed. '
                    .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute variables"> ',
            },

            formula => {
                type => 'leaf',
                value_type => 'string',
                # making formula mandatory makes mandatory setting the
                # compute parameter for a leaf. That's not a
                # desired behavior.
                # mandatory => 1 ,
                description => 'Specify how the computation is done. This string can a Perl expression for '
                    .'integer value or a template for string values. Variables have the same notation '
                    .'than in Perl. Example "$a + $b". '
                    .'Functions like C<&index()> are allowed. '
                    .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute formula"> ',
            },
            replace => {
                type => 'hash',
                index_type => 'string' ,
                cargo => { type => 'leaf', value_type => 'string' } ,
                description => 'Sometime, using the value of a tree leaf is not enough and you need to '
                    .'substitute a replacement for any value you can get. This replacement can be done '
                    .'using a hash like notation within the formula using the %replace hash. Example '
                    .'$replace{$who} , where "who => \'- who_elt\'.  '
                    .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Compute replace">',
            },

            use_eval => {
                type => 'leaf',
                value_type => 'boolean',
                upstream_default   => 0,
                description => 'Set to 1 if you need to perform more complex operations than substition, '
                    .'like extraction with regular expressions. This forces an eval by Perl when '
                    .'computing the formula. The result of the eval is used as the computed value.'
            },
            undef_is => {
                type => 'leaf',
                value_type => 'uniline',
                description => 'Specify a replacement for undefined variables. This replaces C<undef>'
                    .' values in the formula before migrating values. Use \'\' (2 single quotes) '
                    . 'if you want to specify an empty string.  '
                    .'For more details, see L<doc|Config::Model::ValueComputer.pm/"Undefined variables">',
            },
        ],
    ],
];

lib/Config/Model/models/Itself/NonWarpableElement.pl  view on Meta::CPAN

                        },
                    ],
                },
                description =>
                  "points to an array or hash element in the configuration "
                  . "tree using a path computed with value from several other "
                  . "elements in the configuration tree. The available choice "
                  . "of this reference value (or check list) is made from the "
                  . "available keys of the pointed hash element or the values "
                  . "of the pointed array element. The keys of several hashes (or lists) "
                  . "can be combined by using the '+' operator in the formula. "
                  . q(For instance, '! host:$a lan + ! host:foobar lan'. See )
                  . "L<Config::Model::IdElementReference> for more details."
            },

            'replace_follow' => {
                type       => 'leaf',
                level      => 'hidden',
                value_type => 'uniline',
                warp       => {
                    follow  => { t               => '- type' },

lib/Config/Model/models/Itself/NonWarpableElement.pl  view on Meta::CPAN

                warp => {
                    follow  => { t => '- type', },
                    'rules' => [
                        '$t  eq "leaf"' => {
                            level             => 'normal',
                            config_class_name => 'Itself::ComputedValue',
                        },
                    ],
                },
                description =>
                  "compute the default value according to a formula and value "
                  . "from other elements in the configuration tree.",
            },

            'migrate_from' => {
                type       => 'warped_node',
                level      => 'hidden',

                warp => {
                    follow  => { t => '- type', },
                    'rules' => [

lib/Config/Model/models/Itself/WarpValue.pl  view on Meta::CPAN


   'element' 
   => [
       'follow' 
       => {
	   type => 'hash',
	   index_type =>'string',
	   cargo => { type => 'leaf', value_type => 'uniline' } ,
	   description => 'Specify with the path of the configuration element that drives '
           .'the warp, i.e .the elements that control the property change. '
           .'These are specified using a variable name (used in the "rules" formula)'
           .'and a path to fetch the actual value. Example $country => " ! country"',
	  },
       'rules' => {
		   type => 'hash',
		   ordered => 1,
		   index_type => 'string',
		   cargo => {
               type => 'warped_node',
               warp => {
                   rules => [
                       '&get_type =~ /hash|list/' => {
                           config_class_name => 'Itself::WarpableCargoElement'
                       },
                       '&get_type !~ /hash|list/' => {
                           config_class_name => 'Itself::WarpOnlyElement' ,
                       }
                   ]
               }
			    },
		   description => 'Each key of the hash is a test (as formula using the variables defined in "follow" element) that are tried in sequences to apply its associated effects',
		  },
      ],
  ],
];

lib/Config/Model/models/Itself/WarpValue.pod  view on Meta::CPAN

=head1 DESCRIPTION

Configuration classes used by L<Config::Model>

Warp functionality enable a Value object to change its properties (i.e. default value or its type) dynamically according to the value of another Value object locate elsewhere in the configuration tree.

=head1 Elements

=head2 follow

Specify with the path of the configuration element that drives the warp, i.e .the elements that control the property change. These are specified using a variable name (used in the "rules" formula)and a path to fetch the actual value. Example $country...

=head2 rules

Each key of the hash is a test (as formula using the variables defined in "follow" element) that are tried in sequences to apply its associated effects. I< Optional. Type hash of warped_node.  > 

=head1 SEE ALSO

=over

=item *

L<cme>

=back



( run in 0.601 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )