| 1 | package POE::Component::IRC::Plugin::WWW::OhNoRobotCom::Search; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 2 | our $VERSION = '0.003'; | |||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use POE::Component::WWW::OhNoRobotCom::Search; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use base 'POE::Component::IRC::Plugin::BasePoCoWrap'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 0 | ▶ | sub _make_default_args { | ||||||||||
|
Subroutine
_make_default_args: not called CC=1 SCAR=6.9
| |||||||||||||
| 12 | return ( | ||||||||||||
| 13 | 0 | response_event => 'irc_ohnorobot_results', | |||||||||||
| 14 | trigger => qr/^comics?\s+(?=\S+)/i, | ||||||||||||
| 15 | obj_args => { }, | ||||||||||||
| 16 | max_results => 3, | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | } | ||||||||||||
| 19 | |||||||||||||
| 20 | 0 | ▶ | sub _make_poco { | ||||||||||
|
Subroutine
_make_poco: not called CC=2 SCAR=17.9
| |||||||||||||
| 21 | 0 | my $self = shift; | |||||||||||
| 22 | return POE::Component::WWW::OhNoRobotCom::Search->spawn( | ||||||||||||
| 23 | 0 | ▶ | %{ $self->{obj_args} || {} } | ||||||||||
|
Condition0%0/2
$self->{'obj_args'} || {}
MC/DC0%0/1
$self->{'obj_args'} || {}
$self->{'obj_args'}
Truth table0%0/2
A
A= $self->{'obj_args'}
| |||||||||||||
| 24 | ); | ||||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 0 | ▶ | sub _make_response_message { | ||||||||||
|
Subroutine
_make_response_message: not called CC=2 SCAR=17.9
| |||||||||||||
| 28 | 0 | my ( $self, $in_ref ) = @_; | |||||||||||
| 29 | my @out = exists $in_ref->{error} | ||||||||||||
| 30 | ? $in_ref->{error} | ||||||||||||
| 31 | 0 | ▶ | : sort keys %{ $in_ref->{results} }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | |||||||||||||
| 33 | 0 | @out = splice @out, 0, $self->{max_results}; | |||||||||||
| 34 | |||||||||||||
| 35 | 0 | return [ join ' ', @out ]; | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | sub _make_response_event { | ||||||||||
|
Subroutine
_make_response_event: not called CC=2 SCAR=17.9
| |||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||
| 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
| |||||||||||||
| 49 | qw( who channel message type ), | ||||||||||||
| 50 | } | ||||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 0 | ▶ | sub _make_poco_call { | ||||||||||
|
Subroutine
_make_poco_call: not called CC=2 SCAR=17.9
| |||||||||||||
| 54 | 0 | my ( $self, $data_ref ) = @_; | |||||||||||
| 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
| |||||||||||||
| 63 | keys %$data_ref, | ||||||||||||
| 64 | } | ||||||||||||
| 65 | ); | ||||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | 2 | 1; | |||||||||||
| 69 | __END__ | ||||||||||||