ChatBots/Utils.pm

filter: Statementstmt 71.0% 27 / 38 Branchbran 16.6% 2 / 12 Conditioncond 12.5% 2 / 16 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 80.0% 8 / 10 Podpod 100% 3 / 3 totaltotal 48.3% 43 / 89 CC 13 SCAR 42.0
CC
13
Cov
47%
pipeline
132.0
resolve_module
3.0
__ANON__
2.0
CRAP 66.8
↑ Summary ChatBots/Role/Source.pm »
1 package Bot::ChatBots::Utils;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 { our $VERSION = '0.014'; }
5  
6 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Module::Runtime qw< use_module >;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Ouch;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our @EXPORT_OK = qw< load_module pipeline resolve_module >;
12  
13 1 ▶sub load_module { return use_module(resolve_module(@_)) }
Subroutine load_module: called CC=1 SCAR=0.0
Pod documented
14  
15 0 ▶sub pipeline {
Subroutine pipeline: not called CC=11 SCAR=48.8
Pod documented
16 0 ▶ return $_[0] if (@_ == 1) && (ref($_[0]) eq 'CODE');
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and ref $_[0] eq "CODE" 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "CODE"
@_ == 1 ref $_[0] eq "CODE"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "CODE"
ABresult
0X0
100
111
17  
18 0 ▶ state $loaded = eval "use Data::Tubes '0.735002'; 1"
Branch: 1 branch
BranchTrueFalseTotal
state $loaded = eval "use Data::Tubes '0.735002'; 1" or ouch(500, "need Data::Tubes at least 0.736 for pipeline()") 0 0 0
19 or ouch 500, 'need Data::Tubes at least 0.736 for pipeline()';
20  
21 0 my %opts;
22 0 ▶ %opts = %{shift(@_)} if (@_ && ref($_[0]) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if @_ and ref $_[0] eq "HASH" 0 0 0
Condition0%0/3
@_ and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_ ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
23 0 ▶ %opts = %{pop(@_)} if (@_ && ref($_[-1]) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if @_ and ref $_[-1] eq "HASH" 0 0 0
Condition0%0/3
@_ and ref $_[-1] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and ref $_[-1] eq "HASH"
@_ ref $_[-1] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[-1] eq "HASH"
ABresult
0X0
100
111
24 0 ▶ $opts{prefix} //= 'Bot::ChatBots';
Condition0%0/2
$opts{"prefix"} //= "Bot::ChatBots"
l!l
00
MC/DC0%0/1
$opts{"prefix"} //= "Bot::ChatBots"
$opts{"prefix"}
Truth table0%0/2
A
A= $opts{"prefix"}
Aresult
11
00
25 0 ▶ $opts{tap} //= sub { ($_[0]->())[0] }
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ unless exists $opts{pump};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"pump"} 0 0 0
Condition0%0/3
$opts{"tap"} //= sub { ($_[0]->())[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"tap"} //= sub { ($_[0]->())[0]; }
$opts{"tap"} sub { ($_[0]->())[0]; }
Truth table0%0/3
A //= B
A= $opts{"tap"}B= sub { ($_[0]->())[0]; }
ABresult
1X1
011
000
27  
28 0 return Data::Tubes::pipeline(@_, \%opts);
29 } ## end sub pipeline
30  
31 25 ▶sub resolve_module {
Subroutine resolve_module: called CC=3 SCAR=11.0
Pod documented
32 25 my ($name, $prefix) = @_;
33 25 ▶ $prefix //= 'Bot::ChatBots';
Condition100%2/2
$prefix //= "Bot::ChatBots"
l!l
178
MC/DC100%1/1
$prefix //= "Bot::ChatBots"
$prefix
Truth table100%2/2
A
A= $prefix
Aresult
11
00
34 25 ▶ return substr($name, 1) if $name =~ m{\A[+^]}mxs;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A[+^]/msx 12 13 25
35 13 $name =~ s{^(::)?}{::}mxs; # ensure separating "::" in front of $name
36 13 return $prefix . $name;
37 } ## end sub resolve_module
38  
39 3 42;
↑ Summary ChatBots/Role/Source.pm »