blib/lib/POE/Component/IRC/Plugin/CoreList.pm

filter: Statementstmt 33.8% 23 / 68 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 70.0% 7 / 10 Podpod 20.0% 1 / 5 totaltotal 24.0% 31 / 129 SCAR 53.6
CC
20
Cov
22%
_corelist
110.0
S_msg
42.0
S_public
30.0
CRAP 212.0
↑ Summary
1 package POE::Component::IRC::Plugin::CoreList;
2 2 $POE::Component::IRC::Plugin::CoreList::VERSION = '1.04';
3 #ABSTRACT: A POE::Component::IRC plugin that provides Module::CoreList goodness.
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Module::CoreList;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use POE::Component::IRC::Plugin qw(:ALL);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 my $cmds = qr/find|search|release|date/;
11  
12 sub new {
13 1 ▶ my $package = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
14 1 my %args = @_;
15 1 $args{lc $_} = delete $args{$_} for keys %args;
16 1 bless \%args, $package;
17 }
18  
19 sub PCI_register {
20 1 ▶ my ($self,$irc) = @_;
Subroutine PCI_register: called CC=1 SCAR=0.0
Pod undocumented
21 1 $irc->plugin_register( $self, 'SERVER', qw(public msg) );
22 1 return 1;
23 }
24  
25 sub PCI_unregister {
26 1 ▶ return 1;
Subroutine PCI_unregister: called CC=1 SCAR=0.0
Pod undocumented
27 }
28  
29 sub S_public {
30 0 ▶ my ($self,$irc) = splice @_, 0 , 2;
Subroutine S_public: not called CC=5 SCAR=34.0
Pod undocumented
31 0 my ($nick,$userhost) = ( split /!/, ${ $_[0] } )[0..1];
32 0 my $channel = ${ $_[1] }->[0];
33 0 my $what = ${ $_[2] };
34 0 my $mynick = $irc->nick_name();
35 0 ▶ my $cmdstr = $self->{command} || '';
Condition0%0/2
$self->{'command'} || ''
l!l
00
MC/DC0%0/1
$self->{'command'} || ''
$self->{'command'}
Truth table0%0/2
A
A= $self->{'command'}
Aresult
11
00
36 0 my ($string) = $what =~ m/^\s*\Q$mynick\E[\:\,\;\.]?\s*(.*)$/i;
37 0 ▶ return PCI_EAT_NONE unless ( $string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io );
Branch: 1 branch
BranchTrueFalseTotal
unless $string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io 0 0 0
Condition0%0/3
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
!ll&&!rl&&r
000
MC/DC0%0/2
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
$string $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
Truth table0%0/3
A and B
A= $stringB= $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
ABresult
0X0
100
111
38 0 ▶ my ( $command, $module, @args ) = ( $1 || 'release', split /\s+/, $2 );
Condition0%0/2
$1 || 'release'
l!l
00
MC/DC0%0/1
$1 || 'release'
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
39 0 my $reply = _corelist( $command, $module, @args );
40 0 $irc->yield( 'privmsg', $channel, $reply );
41 0 return PCI_EAT_NONE;
42 }
43  
44 sub S_msg {
45 0 ▶ my ($self,$irc) = splice @_, 0 , 2;
Subroutine S_msg: not called CC=6 SCAR=37.4
Pod undocumented
46 0 my ($nick,$userhost) = ( split /!/, ${ $_[0] } )[0..1];
47 0 my $string = ${ $_[2] };
48 0 ▶ my $cmdstr = $self->{command} || '';
Condition0%0/2
$self->{'command'} || ''
l!l
00
MC/DC0%0/1
$self->{'command'} || ''
$self->{'command'}
Truth table0%0/2
A
A= $self->{'command'}
Aresult
11
00
49 0 ▶ return PCI_EAT_NONE unless ( $string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io );
Branch: 1 branch
BranchTrueFalseTotal
unless $string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io 0 0 0
Condition0%0/3
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
!ll&&!rl&&r
000
MC/DC0%0/2
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
$string $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
Truth table0%0/3
A and B
A= $stringB= $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
ABresult
0X0
100
111
50 0 ▶ my ( $command, $module, @args ) = ( $1 || 'release', split /\s+/, $2 );
Condition0%0/2
$1 || 'release'
l!l
00
MC/DC0%0/1
$1 || 'release'
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
51 0 my $reply = _corelist( $command, $module, @args );
52 0 ▶ $irc->yield( ( $self->{privmsg} ? 'privmsg' : 'notice' ), $nick, $reply );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'privmsg'} ? : 0 0 0
53 0 return PCI_EAT_NONE;
54 }
55  
56 sub _corelist {
57 0 ▶ my ($command,$module,@args) = @_;
Subroutine _corelist: not called CC=10 SCAR=47.0
58 # compute the reply
59 0 my $reply;
60 0 ▶ if ( $command =~ /^(?:find|search)$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command =~ /^(?:find|search)$/i) { } 0 0 0
61 0 my @modules = Module::CoreList->find_modules( qr/$module/, @args );
62  
63 # shorten large response lists
64 0 ▶ @modules = (@modules[0..8], '...') if @modules > 9;
Branch: 1 branch
BranchTrueFalseTotal
if @modules > 9 0 0 0
65  
66 0 local $" = ', ';
67 0 ▶ my $where = ( @args ? " in perl @args" : '' );
Branch: 1 branch
BranchTrueFalseTotal
@args ? : 0 0 0
68 0 ▶ $reply = ( @modules
Branch: 1 branch
BranchTrueFalseTotal
@modules ? : 0 0 0
69 ? "Found @modules"
70 : "Found no module matching /$module/" )
71 . $where;
72 }
73 else {
74 0 my ( $release, $patchlevel, $date )
75 = ( Module::CoreList->first_release($module), '', '' );
76 0 ▶ if ($release) {
Branch: 1 branch
BranchTrueFalseTotal
if ($release) 0 0 0
77 0 $date = $Module::CoreList::released{$release};
78 }
79 0 my $rem;
80 0 ▶ if ( Module::CoreList->can('removed_from') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Module::CoreList"->can("removed_from")) 0 0 0
81 0 my $removed = Module::CoreList->removed_from($module);
82 0 ▶ if ( $removed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($removed) 0 0 0
83 0 my $remdate = $Module::CoreList::released{$removed};
84 0 $rem = " and removed from $removed (released on $remdate)";
85 }
86 }
87 0 ▶ $reply = $release
Branch: 2 branches
BranchTrueFalseTotal
$release ? : 0 0 0
$rem ? : 0 0 0
88 ? "$module was first released with perl $release ("
89 . "released on $date)"
90 . ( $rem ? $rem : '' )
91 : "$module is not in the core";
92 }
93 0 return $reply;
94 }
95  
96 2 qq[Apple::Core];
97  
98 __END__
↑ Summary