blib/lib/Bot/BasicBot/Pluggable/Module/Assemble.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 10 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 96.3% 52 / 54 CC 8 SCAR 16.7
CC
8
Cov
100%
told
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.3
↑ Summary
1 package Bot::BasicBot::Pluggable::Module::Assemble;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Bot::BasicBot::Pluggable::Module;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Regexp::Assemble;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 @ISA = qw(Bot::BasicBot::Pluggable::Module);
9 3 $VERSION = '0.03';
10  
11 12 ▶sub told {
Subroutine told: called CC=8 SCAR=20.8
Pod documented
12 12 my ( $self, $mess ) = @_;
13 12 my $bot = $self->bot();
14  
15 # we must be directly addressed
16 return
17 if !( ( defined $mess->{address} && $mess->{address} eq $bot->nick() )
18 12 ▶ || $mess->{channel} eq 'msg' );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mess->{"address"} and $mess->{"address"} eq $bot->nick or $mess->{"channel"} eq "msg" 2 10 12
Condition100%6/6
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick or $mess->{"channel"} eq "msg"
l!l&&r!l&&!r
642
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick
!ll&&!rl&&r
246
MC/DC33%1/3
defined $mess->{"address"} and $mess->{"address"} eq $bot->nick or $mess->{"channel"} eq "msg"
defined $mess->{"address"} $mess->{"address"} eq $bot->nick $mess->{"channel"} eq "msg"
Truth table60%3/5
A and B or C
A= defined $mess->{"address"}B= $mess->{"address"} eq $bot->nickC= $mess->{"channel"} eq "msg"
ABCresult
11X1
0X11
1011
0X00
1000
19  
20 # ignore people we ignore
21 10 ▶ return if $bot->ignore_nick( $mess->{who} );
Branch: 1 branch
BranchTrueFalseTotal
if $bot->ignore_nick($mess->{"who"}) 1 9 10
22  
23 # only answer to our command (which can be our name too)
24 9 ▶ my $src = $bot->nick() eq 'assemble' ? 'raw_body' : 'body';
Branch: 1 branch
BranchTrueFalseTotal
$bot->nick eq 'assemble' ? : 4 5 9
25 9 ▶ return if $mess->{$src} !~ /^\s*assemble(.)(.*)/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $mess->{$src} =~ /^\s*assemble(.)(.*)/i 2 7 9
26  
27 # grab the parameter list
28 7 my ( $delim, $args ) = ( $1, $2 );
29 7 my @args = grep { $_ ne '' } split /\Q$delim\E+/, $args;
30  
31 # ignore short lists
32 7 ▶ return if @args < 2;
Branch: 1 branch
BranchTrueFalseTotal
if @args < 2 3 4 7
33  
34 # compute the assembled regexp and return it
35 4 return Regexp::Assemble->new()->add( @args )->as_string();
36 }
37  
38 1 ▶sub help {'assemble regex1 regex2 regex3'}
Subroutine help: called CC=1 SCAR=0.0
Pod documented
39  
40 3 1;
41  
42 __END__
↑ Summary