Constants/Perl.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 76.7% 43 / 56 CC 8 SCAR 11.2
CC
8
Cov
79%
_init
4.5
new
3.2
constants
3.1
CRAP 3.1
« Constants/XML/SAX/Handler.pm ↑ Summary Constants/XML.pm »
1  
2 package Config::Constants::Perl;
3  
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 our $VERSION = '0.02';
8  
9 13 ▶sub new {
Subroutine new: called CC=3 SCAR=11.8
Pod documented
10 13 my ($class, $file) = @_;
11 13 ▶ (defined $file)
Branch: 1 branch
BranchTrueFalseTotal
defined $file or die "No config file supplied" 13 0 13
12 || die "No config file supplied";
13 13 ▶ my $self = bless({}, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0130
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
14 13 $self->_init($file);
15 12 return $self;
16 }
17  
18 5 ▶sub _init {
Subroutine _init: called CC=4 SCAR=15.0
19 5 my ($self, $file) = @_;
20 5 ▶ (-e $file && -f $file)
Branch: 1 branch
BranchTrueFalseTotal
-e $file and -f $file or die "Bad config file '${file}' either it doesn't exist or it's not a file" 5 0 5
Condition33%1/3
-e $file and -f $file
!ll&&!rl&&r
005
MC/DC0%0/2
-e $file and -f $file
-e $file -f $file
Truth table33%1/3
A and B
A= -e $fileB= -f $file
ABresult
0X0
100
111
21 || die "Bad config file '$file' either it doesn't exist or it's not a file";
22 5 my $config = eval { do $file };
23 5 ▶ (ref($config) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
ref $config eq "HASH" or die "Config file must return a hash" 5 0 5
24 || die "Config file must return a hash";
25 5 $self->{_config} = $config;
26 }
27  
28 12 ▶sub modules { keys %{(shift)->{_config}} }
Subroutine modules: called CC=1 SCAR=0.0
Pod documented
29  
30 21 ▶sub constants {
Subroutine constants: called CC=3 SCAR=11.2
Pod documented
31 21 my ($self, $module) = @_;
32 21 ▶ (defined $module)
Branch: 1 branch
BranchTrueFalseTotal
defined $module or die "You must supply a module name" 21 0 21
33 || die "You must supply a module name";
34 21 ▶ (exists $self->{_config}->{$module})
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"_config"}{$module} or die "The module ($module) is not found in this config" 21 0 21
35 || die "The module ($module) is not found in this config";
36 21 return map {{ $_ => $self->{_config}->{$module}->{$_} }} keys %{$self->{_config}->{$module}};
37 }
38  
39 15 1;
40  
41 __END__
« Constants/XML/SAX/Handler.pm ↑ Summary Constants/XML.pm »