line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Component::WWW::OhNoRobotCom::Search; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
153247
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
73
|
|
9
|
1
|
|
|
1
|
|
9
|
use WWW::OhNoRobotCom::Search; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
10
|
1
|
|
|
1
|
|
380
|
use POE; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use base 'POE::Component::NonBlockingWrapper::Base'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _methods_define { |
14
|
|
|
|
|
|
|
return ( search => '_wheel_entry' ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub search { |
18
|
|
|
|
|
|
|
$poe_kernel->post( shift->{session_id} => search => @_ ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _prepare_wheel { |
22
|
|
|
|
|
|
|
my ( $self, $args ) = @_; |
23
|
|
|
|
|
|
|
$self->{_robo} = WWW::OhNoRobotCom::Search->new( |
24
|
|
|
|
|
|
|
%{ $self->{obj_args} || {} } |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _check_args { |
29
|
|
|
|
|
|
|
my ( $self, $args_ref ) = @_; |
30
|
|
|
|
|
|
|
defined $args_ref->{term} |
31
|
|
|
|
|
|
|
or carp 'Missing `term` argument' |
32
|
|
|
|
|
|
|
and return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _process_request { |
36
|
|
|
|
|
|
|
my ( $self, $in_ref ) = @_; |
37
|
|
|
|
|
|
|
my @search_args; |
38
|
|
|
|
|
|
|
for ( qw(comic_id include max_results lucky) ) { |
39
|
|
|
|
|
|
|
exists $in_ref->{$_} |
40
|
|
|
|
|
|
|
and push @search_args, $_, $in_ref->{$_}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $out_ref = $self->{_robo}->search( $in_ref->{term}, @search_args ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if ( defined $out_ref ) { |
46
|
|
|
|
|
|
|
$in_ref->{results} = $out_ref; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
|
|
|
|
|
|
$in_ref->{error} = $self->{_robo}->error; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |