Plugin/Fortune.pm

filter: Statementstmt 47.8% 11 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod n/a totaltotal 45.1% 14 / 31 CC 2 SCAR 10.0
CC
2
Cov
44%
_make_response_message
6.0
_make_default_args
2.0
_message_into_response_event
2.0
CRAP 2.7
« Plugin/SigFail.pm ↑ Summary Plugin/Magic8Ball.pm »
1 package POE::Component::IRC::Plugin::Fortune;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001003'; # VERSION
7  
8 1 ▶use base 'POE::Component::IRC::Plugin::BaseWrap';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub _make_default_args {
Subroutine _make_default_args: not called CC=1 SCAR=6.9
11 return (
12 0 trigger => qr/^(?=fortune$)/i,
13 response_event => 'irc_fortune',
14 call => [ qw/fortune -s -n 300/ ],
15 );
16 }
17  
18 0 ▶sub _make_response_message {
Subroutine _make_response_message: not called CC=2 SCAR=17.9
19 0 my ( $self, $in_ref ) = @_;
20 0 my $nick = (split /!/, $in_ref->{who})[0];
21  
22 0 open my $fh, "-|", "@{ $self->{call} }"
23 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", join($", @{$self->{"call"};}) or do { print "\nYou do not seem to have `fortune` program installed\n\n"; die "You do not seem to have `fortune` program installed [$!]" } 0 0 0
24 0 print "\nYou do not seem to have `fortune` program installed\n\n";
25 0 die "You do not seem to have `fortune` program installed [$!]";
26 };
27 0 my $fortune = join " ", <$fh>;
28 0 close $fh;
29 0 $fortune =~ s/\s+/ /g;
30  
31 0 return [ "$nick, $fortune" ];
32 }
33  
34 0 ▶sub _message_into_response_event { 'fortune' }
Subroutine _message_into_response_event: not called CC=1 SCAR=6.9
35  
36 1 1;
37 __END__
« Plugin/SigFail.pm ↑ Summary Plugin/Magic8Ball.pm »