Role/Commons/Authority.pm

filter: Statementstmt 88.6% 47 / 53 Branchbran 61.1% 11 / 18 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 81.4% 70 / 86 CC 12 SCAR 18.6
CC
12
Cov
79%
AUTHORITY
11.7
__ANON__
5.2
BEGIN
1.0
CRAP 6.4
« Role/Commons/Tap.pm ↑ Summary Object/AUTHORITY.pm »
1 5 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Role::Commons::Authority;
6  
7 5 ▶use Carp qw[croak];
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use match::simple qw[match];
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Scalar::Util qw[blessed];
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 $Role::Commons::Authority::AUTHORITY = 'cpan:TOBYINK';
14 5 $Role::Commons::Authority::VERSION = '0.104';
15 }
16  
17 5 our %ENABLE_SHARED;
18 5 our %SHARED_AUTHORITIES;
19  
20 4 ▶our $setup_for_class = sub {
Subroutine __ANON__: called CC=3 SCAR=16.5
21 4 my ($role, $package, %args) = @_;
22
23 4 ▶ if ( exists $args{-authorities} )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-authorities"}) 0 4 4
24 {
25 0 $ENABLE_SHARED{ $package } = 1;
26
27 ref($args{-authorities}) eq 'ARRAY' and
28 0 ▶ $SHARED_AUTHORITIES{ $package } = $args{-authorities};
Branch: 1 branch
BranchTrueFalseTotal
ref $args{"-authorities"} eq "ARRAY" and $Role::Commons::Authority::SHARED_AUTHORITIES{$package} = $args{"-authorities"} 0 0 0
29 }
30 5 };
31  
32 sub AUTHORITY
33 11 ▶{
Subroutine AUTHORITY: called CC=10 SCAR=24.6
Pod documented
34 11 my ($invocant, $test) = @_;
35 11 ▶ $invocant = ref $invocant if blessed($invocant);
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($invocant) 0 11 11
36
37 11 my @authorities = do {
38 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
39 11 my @a = ${"$invocant\::AUTHORITY"};
40 11 ▶ if (exists $ENABLE_SHARED{ $invocant })
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Role::Commons::Authority::ENABLE_SHARED{$invocant}) 0 11 11
41 {
42 0 ▶ push @a, @{$SHARED_AUTHORITIES{$invocant} || []};
Condition0%0/2
$Role::Commons::Authority::SHARED_AUTHORITIES{$invocant} || []
l!l
00
MC/DC0%0/1
$Role::Commons::Authority::SHARED_AUTHORITIES{$invocant} || []
$Role::Commons::Authority::SHARED_AUTHORITIES{$invocant}
Truth table0%0/2
A
A= $Role::Commons::Authority::SHARED_AUTHORITIES{$invocant}
Aresult
11
00
43 0 push @a, @{"$invocant\::AUTHORITIES"};
44 }
45 11 @a;
46 };
47
48 11 ▶ if (scalar @_ > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ > 1) 9 2 11
49 {
50 9 my $ok = undef;
51 9 AUTH: for my $A (@authorities)
52 {
53 9 ▶ if (match($A, $test))
Branch: 1 branch
BranchTrueFalseTotal
if (match($A, $test)) 4 5 9
54 {
55 4 $ok = $A;
56 4 last AUTH;
57 }
58 }
59 9 ▶ return $ok if defined $ok;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ok 4 5 9
60
61 @authorities
62 5 ▶ ? croak("Invocant ($invocant) has authority '$authorities[0]'")
Branch: 1 branch
BranchTrueFalseTotal
@authorities ? : 5 0 5
63 : croak("Invocant ($invocant) has no authority defined");
64 }
65
66 2 ▶ wantarray ? @authorities : $authorities[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
67 }
68  
69 5 1;
70  
71 __END__
« Role/Commons/Tap.pm ↑ Summary Object/AUTHORITY.pm »