Utils/Class.pm

filter: Statementstmt 37.1% 13 / 35 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 25.0% 17 / 68 CC 14 SCAR 51.5
CC
14
Cov
22%
load_class
210.0
BEGIN
1.0
BEGIN
1.0
CRAP 173.1
« Utils/Data.pm ↑ Summary Utils/General.pm »
1 #===============================================
2 package Banal::Utils::Class;
3  
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 require Exporter;
6 2 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 @ISA = qw(Exporter);
11 2 @EXPORT_OK = qw( load_class);
12  
13  
14 ##############################################################################"
15 # Utility functions
16 ##############################################################################"
17  
18  
19 #----------------------------------
20 # Function, not a method!
21 #----------------------------------
22 0 ▶sub load_class {
Subroutine load_class: not called CC=14 SCAR=53.5
Pod documented
23 0 my $oclass = shift;
24 0 ▶ my $prefixes = shift || [''];
Condition0%0/2
shift() || ['']
l!l
00
MC/DC0%0/1
shift() || ['']
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
25 0 ▶ my $opts = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
26
27 0 ▶ my $verbose = $opts->{verbose} || 0;
Condition0%0/2
$opts->{'verbose'} || 0
l!l
00
MC/DC0%0/1
$opts->{'verbose'} || 0
$opts->{'verbose'}
Truth table0%0/2
A
A= $opts->{'verbose'}
Aresult
11
00
28 0 ▶ my $on_fail = $opts->{on_fail} || 'warn';
Condition0%0/2
$opts->{'on_fail'} || 'warn'
l!l
00
MC/DC0%0/1
$opts->{'on_fail'} || 'warn'
$opts->{'on_fail'}
Truth table0%0/2
A
A= $opts->{'on_fail'}
Aresult
11
00
29  
30 0 my $class;
31
32 0 foreach my $pfx (@$prefixes) {
33 0 $class = $pfx . $oclass;
34 0 ▶ if (eval "require ($class);") {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require ($class);") { } 0 0 0
35 0 warn "load_class => Just required class '$class'\n";
36 0 return $class;
37 } else {
38 0 ▶ if ($verbose >= 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose >= 6) 0 0 0
39 0 my $msg = "load_class => Tried to load(require) class '$oclass' via package name '$class' without any luck. Oh well. Next time perhaps.\n";
40
41 0 print STDERR $msg;
42 }
43 }
44 }
45
46 0 ▶ if ($on_fail) {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_fail) 0 0 0
47 0 my $msg = "load_class => Unable to load(require) class '$oclass'\n";
48
49 0 ▶ print STDERR $msg if ($on_fail =~ /^print$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $on_fail =~ /^print$/i 0 0 0
50 0 ▶ warn $msg if ($on_fail =~ /^warn$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $on_fail =~ /^warn$/i 0 0 0
51 0 ▶ die $msg if ($on_fail =~ /^die$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $on_fail =~ /^die$/i 0 0 0
52 0 ▶ croak $msg if ($on_fail =~ /^croak$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $on_fail =~ /^croak$/i 0 0 0
53 0 ▶ clutch $msg if ($on_fail =~ /^clutch$/i);
Branch: 1 branch
BranchTrueFalseTotal
if $on_fail =~ /^clutch$/i 0 0 0
54 }
55
56
57 0 return;
58 }
59  
60  
61  
62  
63  
64 2 1;
65  
66  
67 __END__
« Utils/Data.pm ↑ Summary Utils/General.pm »