| 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'} || ''
MC/DC0%0/1
$self->{'command'} || ''
$self->{'command'}
Truth table0%0/2
A
A= $self->{'command'}
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
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
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my ( $command, $module, @args ) = ( $1 || 'release', split /\s+/, $2 ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$1 || 'release'
MC/DC0%0/1
$1 || 'release'
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||
| 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'} || ''
MC/DC0%0/1
$self->{'command'} || ''
$self->{'command'}
Truth table0%0/2
A
A= $self->{'command'}
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | return PCI_EAT_NONE unless ( $string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$string and $string =~ /^\Q$cmdstr\E\s*(?:($cmds))?\s*(.*)/io
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
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my ( $command, $module, @args ) = ( $1 || 'release', split /\s+/, $2 ); | ||||||||||||||||||||||||||
|
Condition0%0/2
$1 || 'release'
MC/DC0%0/1
$1 || 'release'
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||
| 51 | 0 | my $reply = _corelist( $command, $module, @args ); | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | $irc->yield( ( $self->{privmsg} ? 'privmsg' : 'notice' ), $nick, $reply ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | local $" = ', '; | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | my $where = ( @args ? " in perl @args" : '' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $reply = ( @modules | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 77 | 0 | $date = $Module::CoreList::released{$release}; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 0 | my $rem; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( Module::CoreList->can('removed_from') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | my $removed = Module::CoreList->removed_from($module); | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( $removed ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||