NetSDS/Conf.pm

filter: Statementstmt 72.7% 16 / 22 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 55.0% 22 / 40 CC 4 SCAR 22.5
CC
4
Cov
53%
getconf
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.4
« NetSDS/Logger.pm ↑ Summary NetSDS/Class/Abstract.pm »
1 #===============================================================================
2 #
3 # FILE: Conf.pm
4 #
5 # DESCRIPTION: Configuration handling via command line and Config::General
6 #
7 # AUTHOR: Michael Bochkaryov (Rattler), <misha@rattler.kiev.ua>
8 # COMPANY: Net.Style
9 # CREATED: 16.05.2008 12:24:55 EEST
10 #===============================================================================
11  
12 =head1 NAME
13  
14 NetSDS::Conf - API to configuration files
15  
16 =head1 SYNOPSIS
17  
18 use NetSDS::Conf;
19  
20 my $cf = NetSDS::Conf->getconf($conf_file);
21 my $val = $cf->{'parameter'};
22  
23 =head1 DESCRIPTION
24  
25 B<NetSDS::Conf> module is a wrapper to B<Config::General> handler for
26 NetSDS configuration files.
27  
28 This package is for internal usage and is called from B<NetSDS::App>
29 or inherited modules and should be never used directly from applications.
30  
31 =cut
32  
33 package NetSDS::Conf;
34  
35 2 ▶use 5.8.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 2 ▶use Config::General;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 2 ▶use version; our $VERSION = '1.301';
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 #***********************************************************************
44  
45 =over
46  
47 =item B<getconf()> - read parameters from configuration file
48  
49 Paramters: configuration file name
50  
51 Returns: cofiguration as hash reference
52  
53 This method tries to read configuration file and fill object properties
54 with read values.
55  
56 NOTE: Parameters set from command line will not be overriden.
57  
58 =cut
59  
60 #-----------------------------------------------------------------------
61  
62 0 ▶sub getconf {
Subroutine getconf: not called CC=4 SCAR=30.0
Pod documented
63  
64 0 my ( $proto, $cf ) = @_;
65  
66 # Check if configuration file available for reading and read data
67 0 ▶ if ( $cf and ( -f $cf ) and ( -r $cf ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cf and -f $cf and -r $cf) { } 0 0 0
Condition0%0/6
$cf and -f $cf and -r $cf
!ll&&!rl&&r
000
$cf and -f $cf
!ll&&!rl&&r
000
MC/DC0%0/3
$cf and -f $cf and -r $cf
$cf -f $cf -r $cf
Truth table0%0/4
A and B and C
A= $cfB= -f $cfC= -r $cf
ABCresult
0XX0
10X0
1100
1111
68  
69 my $conf = Config::General->new(
70 -ConfigFile => $cf,
71 -AllowMultiOptions => 'yes',
72 -UseApacheInclude => 'yes',
73 -InterPolateVars => 'yes',
74 0 -ConfigPath => [ $ENV{NETSDS_CONF_DIR}, '/etc/NetSDS' ],
75 -IncludeRelative => 'yes',
76 -IncludeGlob => 'yes',
77 -UTF8 => 'yes',
78 );
79  
80 # Parse configuration file
81 0 my %cf_hash = $conf->getall;
82  
83 0 return \%cf_hash;
84  
85 } else {
86 0 return undef;
87 }
88  
89 } ## end sub getconf
90  
91 2 1;
92  
93 __END__
« NetSDS/Logger.pm ↑ Summary NetSDS/Class/Abstract.pm »