| 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.01"; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 4 | ▶ | use Exporter 5.57 (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | sub import { | ||||||||||||||||||||
| 11 | 10 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 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 | 4 | ▶ | no strict qw/refs/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 4 | ▶ | no warnings qw/once/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | 10 | *{"${caller}::with_version"} = \&_with_version; | |||||||||||||||||||
| 29 | 10 | @{"${caller}::EXPORT_OK"} = (); | |||||||||||||||||||
| 30 | 10 | %{"${caller}::EXPORT_TAGS"} = (all => \@{"${caller}::EXPORT_OK"}); | |||||||||||||||||||
| 31 | 10 | @{"${caller}::import"} = Exporter->can('import'); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub _with_version($$) {## no critic | ||||||||||||||||||||
| 35 | 4 | ▶ | my $name = shift; | ||||||||||||||||||
|
Subroutine
_with_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | 4 | my $version = shift; | |||||||||||||||||||
| 37 | 4 | return [$name, $version]; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | sub _key { | ||||||||||||||||||||
| 41 | 10 | ▶ | my $base_version = shift; | ||||||||||||||||||
|
Subroutine
_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | return sub ($) { ## no critic | ||||||||||||||||||||
| 43 | 5 | ▶ | my $name = shift; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 5 | my @versions; | |||||||||||||||||||
| 46 | 5 | ▶ | ($name, @versions) = @$name if ref $name eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 5 | ▶ | unshift @versions => $base_version if defined $base_version; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 5 | my $caller = caller; | |||||||||||||||||||
| 50 | 5 | my $subname = "key_for_$name"; | |||||||||||||||||||
| 51 | 5 | my $value = join '_', $name, @versions; | |||||||||||||||||||
| 52 | 5 | ▶ | my $code = sub () { $value }; ## no critic | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 53 | { | ||||||||||||||||||||
| 54 | 4 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 55 | 5 | *{"${caller}::${subname}"} = $code; | |||||||||||||||||||
| 56 | 5 | push @{"${caller}::EXPORT_OK"} => $subname; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 10 | }; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | sub _keygen { | ||||||||||||||||||||
| 62 | 10 | ▶ | my $base_version = shift; | ||||||||||||||||||
|
Subroutine
_keygen: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 63 | return sub ($;&) { ## no critic | ||||||||||||||||||||
| 64 | 5 | ▶ | my ($name, $generator) = @_; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 65 | 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 {
@_;
}
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 5 | my @versions; | |||||||||||||||||||
| 68 | 5 | ▶ | ($name, @versions) = @$name if ref $name eq 'ARRAY'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 69 | 5 | ▶ | unshift @versions => $base_version if defined $base_version; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 5 | my $caller = caller; | |||||||||||||||||||
| 72 | 5 | my $subname = "gen_key_for_$name"; | |||||||||||||||||||
| 73 | 5 | ▶ | my $code = sub { join '_', $name, @versions, $generator->(@_) }; | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 74 | { | ||||||||||||||||||||
| 75 | 4 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 76 | 5 | *{"${caller}::${subname}"} = $code; | |||||||||||||||||||
| 77 | 5 | push @{"${caller}::EXPORT_OK"} => $subname; | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | 10 | }; | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 4 | 1; | |||||||||||||||||||
| 83 | __END__ | ||||||||||||||||||||