File Coverage

blib/lib/POE/Component/WWW/Alexa/TrafficRank.pm
Criterion Covered Total %
statement 17 28 60.7
branch 0 6 0.0
condition 0 2 0.0
subroutine 7 9 77.7
pod 1 1 100.0
total 25 46 54.3


line stmt bran cond sub pod time code
1             package POE::Component::WWW::Alexa::TrafficRank;
2              
3 1     1   278177 use warnings;
  1         3  
  1         45  
4 1     1   6 use strict;
  1         3  
  1         63  
5              
6             our $VERSION = '1.001004'; # VERSION
7              
8 1     1   5 use POE;
  1         3  
  1         10  
9 1     1   393 use base 'POE::Component::NonBlockingWrapper::Base';
  1         3  
  1         107  
10 1     1   14 use WWW::Alexa::TrafficRank;
  1         2  
  1         380  
11              
12             sub _methods_define {
13 1     1   297 return ( rank => '_wheel_entry' );
14             }
15              
16             sub rank {
17 1     1 1 8002 $poe_kernel->post( shift->{session_id} => rank => @_ );
18             }
19              
20             sub _prepare_wheel {
21 0     0     my $self = shift;
22 0   0       $self->{timeout} ||= 30;
23 0 0         $self->{obj} = WWW::Alexa::TrafficRank->new(
24 0           map { defined $self->{$_} ? ( $_ => $self->{$_} ) : () }
25             qw/agent proxy timeout/
26             );
27             }
28              
29             sub _process_request {
30 0     0     my ( $self, $in_ref ) = @_;
31 0           $in_ref->{uri} =~ s{^(?:ht|f)tps?://|/$}{}gi;
32 0           $in_ref->{rank} = $self->{obj}->get( $in_ref->{uri} );
33 0 0         if ( not length $in_ref->{rank} ) {
    0          
34 0           $in_ref->{error} = 'No result';
35 0           delete $in_ref->{rank};
36             }
37             elsif ( $in_ref->{rank} !~ /^[\d,]+$/ ) {
38 0           $in_ref->{error} = delete $in_ref->{rank};
39             }
40             }
41              
42             1;
43             __END__