| 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
Condition0%0/3
@_ == 1 and ref $_[0] eq "CODE"
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"
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | state $loaded = eval "use Data::Tubes '0.735002'; 1" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
@_ and ref $_[0] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | %opts = %{pop(@_)} if (@_ && ref($_[-1]) eq 'HASH'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and ref $_[-1] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $opts{prefix} //= 'Bot::ChatBots'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"prefix"} //= "Bot::ChatBots"
MC/DC0%0/1
$opts{"prefix"} //= "Bot::ChatBots"
$opts{"prefix"}
Truth table0%0/2
A
A= $opts{"prefix"}
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$opts{"tap"} //= sub {
($_[0]->())[0];
}
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];
}
| |||||||||||||||||||||||||||||
| 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"
MC/DC100%1/1
$prefix //= "Bot::ChatBots"
$prefix
Truth table100%2/2
A
A= $prefix
| |||||||||||||||||||||||||||||
| 34 | 25 | ▶ | return substr($name, 1) if $name =~ m{\A[+^]}mxs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||