| 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
| |||||||||||||||||||||||||||||
| 12 | || die "No config file supplied"; | ||||||||||||||||||||||||||||
| 13 | 13 | ▶ | my $self = bless({}, ref($class) || $class); | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
-e $file and -f $file
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 33 | || die "You must supply a module name"; | ||||||||||||||||||||||||||||
| 34 | 21 | ▶ | (exists $self->{_config}->{$module}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||