Config/General.pm

filter: Statementstmt 64.2% 18 / 28 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 48.0% 24 / 50 CC 7 SCAR 35.0
CC
7
Cov
45%
new
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 33.1
↑ Summary Config.pm »
1 # $Id: General.pm,v 1.2 2003/03/22 17:06:17 cwest Exp $
2 package POEST::Config::General;
3  
4 =pod
5  
6 =head1 NAME
7  
8 POEST::Config::General - Configuration via Config::General
9  
10 =head1 ABSTRACT
11  
12 A poest configurator based on Config::General, a file based
13 configuration.
14  
15 =head1 DESCRIPTION
16  
17 The description of the configuration file is explained in
18 L<Config::General>. This configuration class conforms to the
19 specification explained in L<POEST::Config>.
20  
21 =head2 Example Configuration
22  
23 Hostname localhost
24 Port 2525
25
26 Plugin POEST::Plugin::General
27 Plugin POEST::Plugin::Check::Hostname
28  
29 RequireHost Yes
30 AllowedHost localhost
31 AllowedHost example.com
32  
33 If no configuration file is passed, a list of reasonable default
34 directories are checked for C<poest.conf>.
35  
36  
37 /usr/local/etc
38 /usr/local/etc/poest
39 /etc/poest
40 ./
41 ./etc
42 ~/
43 ~/etc
44 ~/.poest
45  
46 =cut
47  
48 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 $^W = 1;
50  
51 1 ▶use vars qw[$VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 $VERSION = (qw$Revision: 1.2 $)[1];
53  
54 1 ▶use Config::General;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use base qw[POEST::Config];
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
59 0 my ($class, %args) = @_;
60  
61 0 ▶ ATTEMPT: unless ( $args{ConfigFile} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"ConfigFile"}) 0 0 0
62 0 my @locations = qw[
63 /usr/local/etc
64 /usr/local/etc/poest
65 /etc/poest
66 ./
67 ./etc
68 ~/
69 ~/etc
70 ~/.poest
71 ];
72
73 0 foreach ( @locations ) {
74 0 ▶ if ( -e "$_/poest.conf" && -f _ && -s _ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$_/poest.conf" and -f _ and -s _) 0 0 0
Condition0%0/6
-e "$_/poest.conf" and -f _ and -s _
!ll&&!rl&&r
000
-e "$_/poest.conf" and -f _
!ll&&!rl&&r
000
MC/DC0%0/3
-e "$_/poest.conf" and -f _ and -s _
-e "$_/poest.conf" -f _ -s _
Truth table0%0/4
A and B and C
A= -e "$_/poest.conf"B= -f _C= -s _
ABCresult
0XX0
10X0
1100
1111
75 0 $args{ConfigFile} = "$_/poest.conf";
76 0 last ATTEMPT;
77 }
78 }
79 }
80  
81 0 ▶ croak 'ConfigFile is empty' unless $args{ConfigFile};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"ConfigFile"} 0 0 0
82  
83 my $self = { ParseConfig(
84 -ConfigFile => $args{ConfigFile},
85 0 -LowerCaseNames => 1,
86 ) };
87
88 0 return bless $self, $class;
89 }
90  
91 1 1;
92  
93 __END__
↑ Summary Config.pm »