CfgTie/TieGeneric.pm

filter: Statementstmt 100% 36 / 36 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 97.8% 46 / 47 CC 2 SCAR 1.8
CC
2
Cov
97%
TIEHASH
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« CfgTie/TieRealm.pm ↑ Summary CfgTie/TieServ.pm »
1 #!/usr/bin/perl -w
2 #Copyright 1998-2001, Randall Maas. All rights reserved. This program is free
3 #software; you can redistribute it and/or modify it under the same terms as
4 #PERL itself.
5  
6 package CfgTie::TieGeneric;
7 1 ▶use Secure::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use AutoLoader 'AUTOLOAD';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 $VERSION='0.41';
11  
12 =head1 NAME
13  
14 CfgTie::TieGeneric -- A generic hash that automatically binds others
15  
16 =head1 SYNOPSIS
17  
18 This is an associative array that automatially ties other configuration hashes
19  
20 =head1 DESCRIPTION
21  
22 This is a tie to bring other ties together automatically so you, the busy
23 programmer and/or system administrator, don't have to. The related Perl
24 module is not loaded unless it is needed at runtime.
25  
26 my %gen;
27 tie %gen, 'CfgTie::TieGeneric';
28  
29 =head2 Primary, or well-known, keys
30  
31 =over 1
32  
33 =item C<env>
34  
35 This refers directly to the C<ENV> hash.
36  
37 =item C<group>
38  
39 =item C<mail>
40  
41 This is a special key. It forms a hash, with subkeys. See below for more
42 information
43  
44 =item C<net>
45  
46 This is a special key. It forms a hash with additional subkeys. See
47 below for more details.
48  
49 =item C<user>
50  
51 This is a link to the C<TieUser> module (L<CfgTie::TieUser>).
52  
53 =item I<Composite>
54  
55 Composite primary keys are just like absolute file paths. For example, if
56 you wanted to do something like this:
57  
58 my %lusers = $gen{'user'};
59 my $Favorite_User = $lusers{'mygirl'};
60  
61 You could just do:
62  
63 my $Favorite_User = $gen{'/users/mygirl'};
64  
65 =item others...
66  
67 These are the things automatically included in. This will be described below.
68  
69 =back
70  
71 =head2 Subkeys for C<mail>
72  
73 =over 1
74  
75 =item C<aliases>
76  
77 L<CfgTie::TieAliases>
78  
79 =back
80  
81 =head2 Subkeys for C<net>
82  
83 =over 1
84  
85 =item C<host>
86  
87 L<CfgTie::TieHost>
88  
89 =item C<service>
90  
91 L<CfgTie::TieServ>
92  
93 =item C<protocol>
94  
95 L<CfgTie::TieProto>
96  
97 =item C<addr>
98  
99 L<CfgTie::TieNet>
100  
101 =back
102  
103 =head2 How other ties are automatically bound
104  
105 Other keys are automatically (if it all possible) brought in using the
106 following procedure:
107  
108 =over 1
109  
110 =item 1. If it is something already linked to it, that thingy is automatically
111 returned (of course).
112  
113 =item 2. If the key is simple, like F<AABot>, we will try to C<use AABot;>
114 If that works we will tie it and return the results.
115  
116 =item 3. If the key is more complex, like F</OS3/Config>, we will try to see
117 if C<OS3> is already tied (and try to tie it, like above, if not). If that
118 works, we will just look up C<Config> in that hash. If it does not work, we
119 will try to C<use> and C<tie> C<OS3::Config>, C<OS3::TieConfig>, and
120 C<OS3::ConfigTie>. If any of those work, we return the results.
121  
122 =item 4. Otherwise, C<undef> will be returned.
123  
124 =back
125  
126  
127 =head1 See Also
128  
129 L<CfgTie::TieAliases>, L<CfgTie::TieGroup>, L<CfgTie::TieHost>,
130 L<CfgTie::TieMTab>, L<CfgTie::TieNamed>, L<CfgTie::TieNet>,
131 L<CfgTie::TiePh>, L<CfgTie::TieProto>, L<CfgTie::TieRCService>,
132 L<CfgTie::TieRsrc>, L<CfgTie::TieServ>, L<CfgTie::TieShadow>,
133 L<CfgTie::TieUser>
134  
135 =head1 Author
136  
137 Randall Maas (L<mailto:randym@acm.org>, L<http://www.hamline.edu/~rcmaas/>)
138  
139 =cut
140  
141 # These are the builtins that we always add to the global arena...
142  
143 # This forms the abstract tie for the net sub-hash
144 1 my $net_builtins ={host=>['CfgTie::TieHost'],
145 service=>['CfgTie::TieServ'],
146 protocol=>['CfgTie::TieProto'],
147 addr =>['CfgTie::TieNet']
148 };
149  
150 # This forms the abstract tie for the mail sub-hash
151 1 my $mail_builtins={aliases=>['CfgTie::TieAliases']};
152  
153 1 my $builtins =
154 {
155 user => ['CfgTie::TieUser'],
156 group =>['CfgTie::TieGroup'],
157 # env => \%main'ENV,
158 mail => ['CfgTie::TieGeneric', $mail_builtins],
159 net => ['CfgTie::TieGeneric', $net_builtins],
160 runlevel=>['CfgTie::TieRCService'],
161 };
162  
163 1 ▶use CfgTie::TieGroup;
Subroutine BEGIN: called CC=1 SCAR=0.0
164 1 ▶use CfgTie::TieServ;
Subroutine BEGIN: called CC=1 SCAR=0.0
165 1 ▶use CfgTie::TieProto;
Subroutine BEGIN: called CC=1 SCAR=0.0
166 1 ▶use CfgTie::TieNet;
Subroutine BEGIN: called CC=1 SCAR=0.0
167 1 ▶use CfgTie::TieHost;
Subroutine BEGIN: called CC=1 SCAR=0.0
168 1 @ISA=qw(CfgTie::TieGroup CfgTie::TieServ CfgTie::TieProto
169 CfgTie::TieNet CfgTie::TieHost AutoLoader);
170 1 1;
171 __END__
« CfgTie/TieRealm.pm ↑ Summary CfgTie/TieServ.pm »