DiaColloDB/Compat.pm

filter: Statementstmt 56.0% 14 / 25 Branchbran 8.3% 1 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 42.0% 21 / 50 CC 8 SCAR 34.3
CC
8
Cov
38%
usecompat
56.0
nocompat
2.1
__ANON__
2.0
CRAP 30.9
« DiaColloDB/Client/http.pm ↑ Summary DiaColloDB/Upgrade.pm »
1 ## -*- Mode: CPerl -*-
2 ##
3 ## File: DiaColloDB::Compat.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description: DiaColloDB utilities: compatibility modules: top-level wrappers
6  
7 package DiaColloDB::Compat;
8 #use DiaColloDB::Compat::v0_08;
9 #use DiaColloDB::Compat::v0_09;
10 2 ▶use DiaColloDB::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 ##==============================================================================
15 ## Globals
16  
17 2 our @ISA = qw(DiaColloDB::Logger);
18  
19 ##==============================================================================
20 ## Utilities
21  
22 ## $bool = $that->usecompat($pkg)
23 ## + attempts to "use DiaColloDB::Compat::$pkg", throwing an error on failure
24 0 ▶sub usecompat {
Subroutine usecompat: not called CC=7 SCAR=40.3
Pod documented
25 0 ▶ my $that = UNIVERSAL::isa($_[0],__PACKAGE__) ? shift : __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 0 0 0
26 0 my $pkg = shift;
27 0 (my $file = $pkg) =~ s{::}{/}g;
28 0 ▶ $file .= ".pm" if ($file !~ /\.pm$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /\.pm$/ 0 0 0
29 0 ▶ $file = "DiaColloDB/Compat/$file" if ($file !~ m{^DiaColloDB/Compat/});
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ m[^DiaColloDB/Compat/] 0 0 0
30 0 my ($rc);
31 0 eval { $rc = require $file };
32 0 ▶ $that->logconfess("failed to load compatibility package $pkg".($@ ? ": $@" : '')) if ($@ || !$rc);
Branch: 2 branches
BranchTrueFalseTotal
if $@ or not $rc 0 0 0
$@ ? : 0 0 0
Condition0%0/3
$@ or not $rc
l!l&&r!l&&!r
000
MC/DC0%0/2
$@ or not $rc
$@ not $rc
Truth table0%0/3
A or not(B)
A= $@B= not $rc
ABresult
1X1
011
000
33 0 return $rc;
34 }
35  
36 ## \&dummyMethodCode = $that->nocompat($methodName)
37 ## + wrapper for subclasses which do not implement some API methods
38 12 ▶sub nocompat {
Subroutine nocompat: called CC=2 SCAR=7.6
Pod documented
39 12 ▶ my $that = UNIVERSAL::isa($_[0],__PACKAGE__) ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 12 0 12
40 12 my $method = shift;
41 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 $_[0]->logconfess("method $method() not supported by compatibility wrapper");
43 12 };
44 }
45  
46 ##==============================================================================
47 ## Footer
48 2 1; ##-- be happy
« DiaColloDB/Client/http.pm ↑ Summary DiaColloDB/Upgrade.pm »