line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::ChatBots::Utils; |
2
|
3
|
|
|
3
|
|
20647
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
133
|
|
4
|
|
|
|
|
|
|
{ our $VERSION = '0.006'; } |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
84
|
use 5.010; |
|
3
|
|
|
|
|
15
|
|
7
|
3
|
|
|
3
|
|
11
|
use Exporter 'import'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
111
|
|
8
|
3
|
|
|
3
|
|
1160
|
use Module::Runtime qw< use_module >; |
|
3
|
|
|
|
|
3105
|
|
|
3
|
|
|
|
|
17
|
|
9
|
3
|
|
|
3
|
|
1684
|
use Ouch; |
|
3
|
|
|
|
|
8585
|
|
|
3
|
|
|
|
|
1024
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw< load_module pipeline resolve_module >; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
1
|
27
|
sub load_module { return use_module(resolve_module(@_)) } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub pipeline { |
16
|
0
|
0
|
0
|
0
|
1
|
0
|
return $_[0] if (@_ == 1) && (ref($_[0]) eq 'CODE'); |
17
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
0
|
state $loaded = eval "use Data::Tubes '0.735002'; 1" |
19
|
|
|
|
|
|
|
or ouch 500, 'need Data::Tubes at least 0.736 for pipeline()'; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my %opts; |
22
|
0
|
0
|
0
|
|
|
0
|
%opts = %{shift(@_)} if (@_ && ref($_[0]) eq 'HASH'); |
|
0
|
|
|
|
|
0
|
|
23
|
0
|
0
|
0
|
|
|
0
|
%opts = %{pop(@_)} if (@_ && ref($_[-1]) eq 'HASH'); |
|
0
|
|
|
|
|
0
|
|
24
|
0
|
|
0
|
|
|
0
|
$opts{prefix} //= 'Bot::ChatBots'; |
25
|
0
|
|
|
0
|
|
0
|
$opts{tap} //= sub { ($_[0]->())[0] } |
26
|
0
|
0
|
0
|
|
|
0
|
unless exists $opts{pump}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
return Data::Tubes::pipeline(@_, \%opts); |
29
|
|
|
|
|
|
|
} ## end sub pipeline |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub resolve_module { |
32
|
25
|
|
|
25
|
1
|
11642
|
my ($name, $prefix) = @_; |
33
|
25
|
|
100
|
|
|
112
|
$prefix //= 'Bot::ChatBots'; |
34
|
25
|
100
|
|
|
|
134
|
return substr($name, 1) if $name =~ m{\A[+^]}mxs; |
35
|
13
|
|
|
|
|
57
|
$name =~ s{^(::)?}{::}mxs; # ensure separating "::" in front of $name |
36
|
13
|
|
|
|
|
42
|
return $prefix . $name; |
37
|
|
|
|
|
|
|
} ## end sub resolve_module |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
42; |