| 1 | package Cache::Keys::DSL; | ||||||||||||||||||||
| 2 | 4 | ▶ | use 5.008001; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 4 | our $VERSION = "0.02"; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 4 | ▶ | use Exporter 5.57 (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 10 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 11 | 10 | my ($class, %args) = @_; | |||||||||||||||||||
| 12 | 10 | my $caller = caller; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 10 | my $base_version = $args{base_version}; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 10 | my %export; | |||||||||||||||||||
| 17 | 10 | $export{key} = _key($base_version); | |||||||||||||||||||
| 18 | 10 | $export{keygen} = _keygen($base_version); | |||||||||||||||||||
| 19 | 10 | for my $name (keys %export) { | |||||||||||||||||||
| 20 | 20 | my $code = $export{$name}; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 4 | ▶ | no strict qw/refs/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | 20 | *{"${caller}::${name}"} = $code; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | { | ||||||||||||||||||||
| 27 | 10 | local $Exporter::ExportLevel = 1; | |||||||||||||||||||
| 28 | 10 | Exporter->import('import'); | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 4 | ▶ | no strict qw/refs/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | 4 | ▶ | no warnings qw/once/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | 10 | *{"${caller}::with_version"} = \&_with_version; | |||||||||||||||||||
| 34 | 10 | @{"${caller}::EXPORT_OK"} = (); | |||||||||||||||||||
| 35 | 10 | %{"${caller}::EXPORT_TAGS"} = (all => \@{"${caller}::EXPORT_OK"}); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 4 | ▶ | sub _with_version($$) {## no critic | ||||||||||||||||||
|
Subroutine
_with_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | 4 | my $name = shift; | |||||||||||||||||||
| 40 | 4 | my $version = shift; | |||||||||||||||||||
| 41 | 4 | return [$name, $version]; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 10 | ▶ | sub _key { | ||||||||||||||||||
|
Subroutine
_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 45 | 10 | my $base_version = shift; | |||||||||||||||||||
| 46 | 5 | ▶ | return sub ($) { ## no critic | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 47 | 5 | my $name = shift; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 5 | my @versions; | |||||||||||||||||||
| 50 | 5 | ▶ | ($name, @versions) = @$name if ref $name eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 5 | ▶ | unshift @versions => $base_version if defined $base_version; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 5 | my $caller = caller; | |||||||||||||||||||
| 54 | 5 | my $subname = "key_for_$name"; | |||||||||||||||||||
| 55 | 5 | my $value = join '_', $name, @versions; | |||||||||||||||||||
| 56 | 0 | ▶ | my $code = sub () { $value }; ## no critic | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 57 | { | ||||||||||||||||||||
| 58 | 4 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 59 | 5 | *{"${caller}::${subname}"} = $code; | |||||||||||||||||||
| 60 | 5 | push @{"${caller}::EXPORT_OK"} => $subname; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | 10 | }; | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 10 | ▶ | sub _keygen { | ||||||||||||||||||
|
Subroutine
_keygen: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 66 | 10 | my $base_version = shift; | |||||||||||||||||||
| 67 | 5 | ▶ | return sub ($;&) { ## no critic | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 68 | 5 | my ($name, $generator) = @_; | |||||||||||||||||||
| 69 | 5 | ▶ | $generator ||= sub { @_ }; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$generator ||= sub {
@_;
}
MC/DC0%0/2
$generator ||= sub {
@_;
}
$generator
sub {
@_;
}
Truth table33%1/3
A ||= B
A= $generatorB= sub {
@_;
}
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 5 | my @versions; | |||||||||||||||||||
| 72 | 5 | ▶ | ($name, @versions) = @$name if ref $name eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 5 | ▶ | unshift @versions => $base_version if defined $base_version; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 5 | my $caller = caller; | |||||||||||||||||||
| 76 | 5 | my $subname = "gen_key_for_$name"; | |||||||||||||||||||
| 77 | 5 | ▶ | my $code = sub { join '_', $name, @versions, $generator->(@_) }; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 78 | { | ||||||||||||||||||||
| 79 | 4 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 80 | 5 | *{"${caller}::${subname}"} = $code; | |||||||||||||||||||
| 81 | 5 | push @{"${caller}::EXPORT_OK"} => $subname; | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | 10 | }; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 4 | 1; | |||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||