blib/lib/POE/Component/IRC/Plugin/WWW/OhNoRobotCom/Search.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod n/a totaltotal 39.1% 18 / 46 SCAR 24.0
CC
5
Cov
38%
_make_poco
6.0
_make_response_message
6.0
_make_response_event
6.0
CRAP 11.0
↑ Summary Build »
1 package POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search;
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 = '0.002';
7  
8 1 ▶use POE::Component::WWW::OhNoRobotCom::Search;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'POE::Component::IRC::Plugin::BasePoCoWrap';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub _make_default_args {
12 return (
13 0 ▶ response_event => 'irc_ohnorobot_results',
Subroutine _make_default_args: not called CC=1 SCAR=6.9
14 trigger => qr/^comics?\s+(?=\S+)/i,
15 obj_args => { },
16 max_results => 3,
17 );
18 }
19  
20 sub _make_poco {
21 0 ▶ my $self = shift;
Subroutine _make_poco: not called CC=2 SCAR=17.9
22 return POE::Component::WWW::OhNoRobotCom::Search->spawn(
23 0 ▶ %{ $self->{obj_args} || {} }
Branch: 1 branch
BranchTrueFalseTotal
$self->{"obj_args"} or {} 0 0 0
24 );
25 }
26  
27 sub _make_response_message {
28 0 ▶ my ( $self, $in_ref ) = @_;
Subroutine _make_response_message: not called CC=2 SCAR=17.9
29 my @out = exists $in_ref->{error}
30 ? $in_ref->{error}
31 0 ▶ : sort keys %{ $in_ref->{results} };
Branch: 1 branch
BranchTrueFalseTotal
exists $in_ref->{'error'} ? : 0 0 0
32  
33 0 @out = splice @out, 0, $self->{max_results};
34  
35 0 return [ join ' ', @out ];
36 }
37  
38 sub _make_response_event {
39 0 ▶ my $self = shift;
Subroutine _make_response_event: not called CC=2 SCAR=17.9
40 0 my $in_ref = shift;
41  
42 return {
43 ( exists $in_ref->{error}
44 ? ( error => $in_ref->{error} )
45 : ( results => $in_ref->{results} )
46 ),
47 term => $in_ref->{term},
48 0 ▶ map { $_ => $in_ref->{"_$_"} }
Branch: 1 branch
BranchTrueFalseTotal
exists $in_ref->{'error'} ? : 0 0 0
49 qw( who channel message type ),
50 }
51 }
52  
53 sub _make_poco_call {
54 0 ▶ my ( $self, $data_ref ) = @_;
Subroutine _make_poco_call: not called CC=2 SCAR=17.9
55  
56 $self->{poco}->search({
57 event => '_poco_done',
58 term => delete $data_ref->{what},
59 map( +( exists $self->{$_} ? ( $_ => $self->{$_} ) : () ),
60 qw(max_results comic_id include lucky)
61 ),
62 0 ▶ map +( "_$_" => $data_ref->{$_} ),
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{$_} ? : 0 0 0
63 keys %$data_ref,
64 }
65 );
66 }
67  
68 1 1;
69 __END__
↑ Summary Build »