Lookup/File.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 89.3% 42 / 47 CC 5 SCAR 10.6
CC
5
Cov
89%
init
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Lookup.pm ↑ Summary Lookup/Local.pm »
1 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Property::Lookup::File;
6 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $Property::Lookup::File::VERSION = '1.101400';
8 }
9 # ABSTRACT: File-based property lookup layer
10 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use parent 'Property::Lookup::Hash';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 __PACKAGE__->mk_scalar_accessors(qw(filename));
13  
14 1 ▶sub init {
Subroutine init: called CC=5 SCAR=16.4
Pod documented
15 1 my $self = shift;
16 1 $self->SUPER::init(@_);
17 1 ▶ if (my $conf_file = $self->filename) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $conf_file = $self->filename) 1 0 1
18  
19 # replace dollar-variables with their environment equivalent; also
20 # some special definitions
21 1 ▶ open my $fh, '<', $conf_file or die "can't open $conf_file: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $conf_file or die "can't open ${conf_file}: $!\n" 1 0 1
22 1 my $yaml = do { local $/; <$fh> };
23 1 ▶ close $fh or die "can't close $conf_file: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "can't close ${conf_file}: $!\n" 1 0 1
24 1 $ENV{SELF} = dirname($self->filename);
25 1 ▶ $yaml =~ s/\$(\w+)/$ENV{$1} || "\$$1"/ge;
Condition50%1/2
$ENV{$1} || "\$$1"
l!l
10
MC/DC0%0/1
$ENV{$1} || "\$$1"
$ENV{$1}
Truth table50%1/2
A
A= $ENV{$1}
Aresult
11
00
26 1 require YAML;
27 1 $self->hash(YAML::Load($yaml));
28 }
29 }
30 2 1;
31  
32  
33 __END__
« Lookup.pm ↑ Summary Lookup/Local.pm »