| 1 | package App::ZofCMS::Plugin::GooglePageRank; | ||||||||||||||||||||||||||||
| 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.001010'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use WWW::Google::PageRank; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use base 'App::ZofCMS::Plugin::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub _key { 'plug_google_page_rank' } | ||||||||||||||||||||||||||
|
Subroutine
_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub _defaults { | ||||||||||||||||||||||||||
|
Subroutine
_defaults: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | return ( | ||||||||||||||||||||||||||||
| 14 | 0 | timeout => 20, | |||||||||||||||||||||||||||
| 15 | agent => 'Opera 9.6', | ||||||||||||||||||||||||||||
| 16 | host => 'suggestqueries.google.com', | ||||||||||||||||||||||||||||
| 17 | cell => 't', | ||||||||||||||||||||||||||||
| 18 | key => 'plug_google_page_rank', | ||||||||||||||||||||||||||||
| 19 | # uri => 'obtain from query', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _do { | ||||||||||||||||||||||||||
|
Subroutine
_do: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 23 | 0 | my ( $self, $conf, $t, $q, $config ) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if ( ref $conf->{uri} eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | $conf->{uri} = $conf->{uri}->( $t, $q, $config ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | $conf->{uri} = 'http://' . $ENV{HTTP_HOST} . $ENV{REQUEST_URI} | ||||||||||||||||||||||||||||
| 30 | unless defined $conf->{uri} | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | and length $conf->{uri}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $conf->{"uri"} and length $conf->{"uri"}
MC/DC0%0/2
defined $conf->{"uri"} and length $conf->{"uri"}
defined $conf->{"uri"}
length $conf->{"uri"}
Truth table0%0/3
A and B
A= defined $conf->{"uri"}B= length $conf->{"uri"}
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | my $pr = WWW::Google::PageRank->new( | ||||||||||||||||||||||||||||
| 34 | timeout => $conf->{timeout}, | ||||||||||||||||||||||||||||
| 35 | agent => $conf->{agent}, | ||||||||||||||||||||||||||||
| 36 | host => $conf->{host}, | ||||||||||||||||||||||||||||
| 37 | 0 | ); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( ref $conf->{uri} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | for ( @{ $conf->{uri} } ) { | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | unless ( m|https?://| ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | $_ = "http://$_"; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | my $rank = $pr->get($_); | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | push @{ $t->{ $conf->{cell} }{ $conf->{key} } }, +{ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | rank => defined $rank ? $rank : 'N/A', | ||||||||||||||||||||||||||||
| 48 | uri => $_, | ||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless ( $conf->{uri} =~ m|https?://| ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $conf->{uri} = "http://$conf->{uri}"; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 0 | my $rank = $pr->get( $conf->{uri} ); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | $t->{ $conf->{cell} }{ $conf->{key} } = defined $rank ? $rank : 'N/A'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | 1; | |||||||||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||||||||||