blib/lib/WWW/Alexa/TrafficRank.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 81.2% 39 / 48 CC 7 SCAR 12.6
CC
7
Cov
79%
new
5.5
get
3.6
BEGIN
1.0
CRAP 3.5
↑ Summary
1 package WWW::Alexa::TrafficRank;
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 2 $VERSION = '1.11';
9
10 sub new
11 1 ▶{
Subroutine new: called CC=5 SCAR=17.0
Pod documented
12 1 my $class = shift;
13 1 my %par = @_;
14 1 my $self;
15
16 1 ▶ $self->{ua} = LWP::UserAgent->new(agent => $par{agent} || 'Opera 11.1') or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"ua"} = "LWP::UserAgent"->new("agent", $par{"agent"} || "Opera 11.1") or return 1 0 1
Condition50%1/2
$par{'agent'} || 'Opera 11.1'
l!l
01
MC/DC0%0/1
$par{'agent'} || 'Opera 11.1'
$par{'agent'}
Truth table50%1/2
A
A= $par{'agent'}
Aresult
11
00
17 1 ▶ $self->{ua}->proxy('http', $par{proxy}) if $par{proxy};
Branch: 1 branch
BranchTrueFalseTotal
if $par{"proxy"} 0 1 1
18 1 ▶ $self->{ua}->timeout($par{timeout}) if $par{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $par{"timeout"} 0 1 1
19
20 1 bless ($self, $class);
21 }
22
23 sub get
24 1 ▶{
Subroutine get: called CC=3 SCAR=12.7
Pod documented
25 1 my ($self, $domain) = @_;
26
27 1 ▶ return unless defined $domain;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $domain 0 1 1
28
29 1 my $res = $self->{ua}->get("http://xml.alexa.com/data?cli=10&dat=nsa&url=$domain");
30 1 ▶ return $res->status_line if !$res->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->is_success 1 0 1
31
32 0 my ($rank) = $res->content =~ /<POPULARITY URL=".+" TEXT="(\d+)"/i;
33
34 0 return $rank;
35 }
36
37 2 1;
38
39 __END__
↑ Summary