1Config::Model::AnnotatiUosne(r3)Contributed Perl DocumenCtoantfiiogn::Model::Annotation(3)
2
3
4

NAME

6       Config::Model::Annotation - Read and write configuration annotations
7

VERSION

9       version 2.138
10

SYNOPSIS

12        use Config::Model ;
13
14        # define configuration tree object
15        my $model = Config::Model->new ;
16        $model ->create_config_class (
17           name => "MyClass",
18           element => [
19               [qw/foo bar/] => {
20                   type => 'leaf',
21                   value_type => 'string'
22               },
23               baz => {
24                   type => 'hash',
25                   index_type => 'string' ,
26                   cargo => {
27                       type => 'leaf',
28                       value_type => 'string',
29                   },
30               },
31
32           ],
33        ) ;
34
35        my $inst = $model->instance(root_class_name => 'MyClass' );
36
37        my $root = $inst->config_root ;
38
39        # put some data in config tree the hard way
40        $root->fetch_element('foo')->store('yada') ;
41        $root->fetch_element('baz')->fetch_with_id('en')->store('hello') ;
42
43        # put annotation the hard way
44        $root->fetch_element('foo')->annotation('english') ;
45        $root->fetch_element('baz')->fetch_with_id('en')->annotation('also english') ;
46
47        # put more data the easy way
48        my $steps = 'baz:fr=bonjour#french baz:hr="dobar dan"#croatian';
49        $root->load( steps => $steps ) ;
50
51        # dump resulting tree with annotations
52        print $root->dump_tree;
53
54        # save annotations
55        my $annotate_saver = Config::Model::Annotation
56         -> new (
57                 config_class_name => 'MyClass',
58                 instance => $inst ,
59                 root_dir => '/tmp/', # for test
60                ) ;
61        $annotate_saver->save ;
62
63        # now check content of /tmp/config-model/MyClass-note.pl
64

DESCRIPTION

66       This module provides an object that read and write annotations (a bit
67       like comments) to and from a configuration tree and save them in a file
68       (not configuration file). This module can be used to save annotation
69       for configuration files that do not support comments.
70
71       THis module should not be used for configuration files that support
72       comments.
73
74       Depending on the effective id of the process, the annotation is saved
75       in:
76
77       ·   "/var/lib/config-model/<model_name>-note.yml" for root (EUID == 0)
78
79       ·   "~/.config-model/<model_name>-note.yml" for normal user (EUID > 0)
80

CONSTRUCTOR

82       Quite standard. The constructor is passed a Config::Model::Instance
83       object.
84

METHODS

86   save
87       Save annotations in a file (See DESCRIPTION)
88
89   load
90       Loads annotations from a file (See DESCRIPTION)
91

CAVEATS

93       This module is currently not used.
94

AUTHOR

96       Dominique Dumont, (ddumont at cpan dot org)
97

SEE ALSO

99       Config::Model, Config::Model::Node, Config::Model::Loader,
100       Config::Model::Searcher, Config::Model::Value,
101

AUTHOR

103       Dominique Dumont
104
106       This software is Copyright (c) 2005-2019 by Dominique Dumont.
107
108       This is free software, licensed under:
109
110         The GNU Lesser General Public License, Version 2.1, February 1999
111
112
113
114perl v5.30.1                      2020-01-29      Config::Model::Annotation(3)
Impressum