Server/Bayeux/Utilities.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 92.8% 13 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 93.6% 44 / 47 CC 9 SCAR 19.5
CC
9
Cov
95%
channel_match
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« Server/Bayeux/Message/Factory.pm ↑ Summary Client/Bayeux/Utilities.pm »
1 package POE::Component::Server::Bayeux::Utilities;
2  
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 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 our %EXPORT_TAGS = ( all => [qw(channel_match)] );
8 4 our @EXPORT_OK = qw(channel_match);
9  
10 10 ▶sub channel_match {
Subroutine channel_match: called CC=9 SCAR=22.0
Pod undocumented
11 10 my ($from, $to) = @_;
12  
13 # Should channel $from be delivered to someone subscribed to channel $to?
14  
15 10 ▶ return 1 if $from eq $to;
Branch: 1 branch
BranchTrueFalseTotal
if $from eq $to 1 9 10
16  
17 9 my @from = split /\//, $from;
18 9 my @to = split /\//, $to;
19  
20 9 ▶ for (my $i = 0; $i <= $#from; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#from) 23 1 24
21 23 ▶ return 0 if ! defined $to[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $to[$i] 1 22 23
22  
23 # Match all
24 22 ▶ return 1 if $to[$i] eq '**';
Branch: 1 branch
BranchTrueFalseTotal
if $to[$i] eq "**" 1 21 22
25  
26 # If simple glob '*' and from has no more parts
27 21 ▶ return 1 if $to[$i] eq '*' && $#from == $i;
Branch: 1 branch
BranchTrueFalseTotal
if $to[$i] eq "*" and $#from == $i 2 19 21
Condition100%3/3
$to[$i] eq "*" and $#from == $i
!ll&&!rl&&r
1632
MC/DC100%2/2
$to[$i] eq "*" and $#from == $i
$to[$i] eq "*" $#from == $i
Truth table100%3/3
A and B
A= $to[$i] eq "*"B= $#from == $i
ABresult
0X0
100
111
28  
29 19 ▶ return 0 if $from[$i] ne $to[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $from[$i] ne $to[$i] 4 15 19
30 }
31  
32 1 ▶ return 0 if int @to > int @from;
Branch: 1 branch
BranchTrueFalseTotal
if int @to > int @from 1 0 1
33  
34 # If here, it matched
35 0 return 1;
36 }
37  
38 4 1;
« Server/Bayeux/Message/Factory.pm ↑ Summary Client/Bayeux/Utilities.pm »