ZofCMS/Plugin/GooglePageRank.pm

filter: Statementstmt 42.4% 14 / 33 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 30.5% 18 / 59 CC 10 SCAR 42.4
CC
10
Cov
28%
_do
110.0
_key
2.0
_defaults
2.0
CRAP 69.2
« ZofCMS/Plugin/BreadCrumbs.pm ↑ Summary ZofCMS/Plugin/FileTypeIcon.pm »
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
BranchTrueFalseTotal
if (ref $conf->{"uri"} eq "CODE") 0 0 0
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
BranchTrueFalseTotal
unless defined $conf->{"uri"} and length $conf->{"uri"} 0 0 0
Condition0%0/3
defined $conf->{"uri"} and length $conf->{"uri"}
!ll&&!rl&&r
000
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"}
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if (ref $conf->{'uri'} eq 'ARRAY') { } 0 0 0
40 0 for ( @{ $conf->{uri} } ) {
41 0 ▶ unless ( m|https?://| ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (m[https?://]) 0 0 0
42 0 $_ = "http://$_";
43 }
44  
45 0 my $rank = $pr->get($_);
46 0 ▶ push @{ $t->{ $conf->{cell} }{ $conf->{key} } }, +{
Branch: 1 branch
BranchTrueFalseTotal
defined $rank ? : 0 0 0
47 rank => defined $rank ? $rank : 'N/A',
48 uri => $_,
49 };
50 }
51 }
52 else {
53 0 ▶ unless ( $conf->{uri} =~ m|https?://| ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($conf->{"uri"} =~ m[https?://]) 0 0 0
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
BranchTrueFalseTotal
defined $rank ? : 0 0 0
58 }
59 }
60  
61 1 1;
62 __END__
« ZofCMS/Plugin/BreadCrumbs.pm ↑ Summary ZofCMS/Plugin/FileTypeIcon.pm »