| 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
| |||||||||||||||||||||||||||||||||
| 26 | 0 | my $pkg = shift; | |||||||||||||||||||||||||||||||
| 27 | 0 | (my $file = $pkg) =~ s{::}{/}g; | |||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $file .= ".pm" if ($file !~ /\.pm$/); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $file = "DiaColloDB/Compat/$file" if ($file !~ m{^DiaColloDB/Compat/}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$@ or not $rc
MC/DC0%0/2
$@ or not $rc
$@
not $rc
Truth table0%0/3
A or not(B)
A= $@B= not $rc
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||