GIN/Keys/Expand.pm

filter: Statementstmt 100% 36 / 36 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 6 totaltotal 82.2% 51 / 62 CC 4 SCAR 6.6
CC
4
Cov
93%
expand_key
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« GIN/Query/Set.pm ↑ Summary GIN/Extract/Class.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Search::GIN::Keys::Expand;
4  
5 4 our $VERSION = '0.11';
6  
7 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 23 ▶sub expand_keys {
Subroutine expand_keys: called CC=1 SCAR=0.0
Pod undocumented
12 23 my ( $self, @keys ) = @_;
13 23 return map { $self->expand_key($_) } @keys;
14 }
15  
16 82 ▶sub expand_key {
Subroutine expand_key: called CC=4 SCAR=14.5
Pod undocumented
17 82 my ( $self, $value, %args ) = @_;
18  
19 82 ▶ return $self->expand_key_string($value) if not ref $value;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 43 39 82
20  
21 39 my $method = "expand_keys_" . lc ref($value);
22  
23 39 ▶ croak("Don't know how to expand $value in key") if $method =~ /::/ or not $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ /::/ or not $self->can($method) 0 39 39
Condition33%1/3
$method =~ /::/ or not $self->can($method)
l!l&&r!l&&!r
0039
MC/DC0%0/2
$method =~ /::/ or not $self->can($method)
$method =~ /::/ not $self->can($method)
Truth table33%1/3
A or not(B)
A= $method =~ /::/B= not $self->can($method)
ABresult
1X1
011
000
24  
25 39 return $self->$method($value);
26 }
27  
28 33 ▶sub expand_key_prepend {
Subroutine expand_key_prepend: called CC=1 SCAR=0.0
Pod undocumented
29 33 my ( $self, $prefix, @keys ) = @_;
30 33 return map { [ $prefix, @$_ ] } @keys;
31 }
32  
33 43 ▶sub expand_key_string {
Subroutine expand_key_string: called CC=1 SCAR=0.0
Pod undocumented
34 43 my ( $self, $str ) = @_;
35 43 return [ $str ];
36 }
37  
38 18 ▶sub expand_keys_array {
Subroutine expand_keys_array: called CC=1 SCAR=0.0
Pod undocumented
39 18 my ( $self, $array ) = @_;
40 18 return map { $self->expand_key($_) } @$array;
41 }
42  
43 21 ▶sub expand_keys_hash {
Subroutine expand_keys_hash: called CC=1 SCAR=0.0
Pod undocumented
44 21 my ( $self, $hash ) = @_;
45  
46 return map {
47 21 $self->expand_key_prepend(
48 $_,
49 33 $self->expand_key($hash->{$_})
50 );
51 } keys %$hash;
52 }
53  
54 4 1;
« GIN/Query/Set.pm ↑ Summary GIN/Extract/Class.pm »