Coveralia.pm

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 5 / 10 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 77.2% 51 / 66 CC 10 SCAR 17.3
CC
10
Cov
82%
_parse_tree
8.9
_native_setup_search
3.1
BEGIN
1.0
CRAP 5.6
« Coveralia/Result/Album.pm ↑ Summary Coveralia/Result/Artist.pm »
1 package WWW::Search::Coveralia;
2  
3 2 ▶use 5.014000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent qw/WWW::Search/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.001';
9 2 our $MAINTAINER = 'Marius Gavrilescu <marius@ieval.ro>';
10  
11 sub DEFAULT_URL;
12 sub process_result;
13  
14 4 ▶sub _native_setup_search{
Subroutine _native_setup_search: called CC=3 SCAR=11.4
15 4 my ($self, $native_query, $options) = @_;
16 4 $self->agent_email('marius@ieval.ro');
17 4 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
40
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
18 4 ▶ my $base_url = $options->{search_url} // $self->DEFAULT_URL;
Condition33%1/3
$options->{"search_url"} // $self->DEFAULT_URL
l!l&&r!l&&!r
040
MC/DC0%0/2
$options->{"search_url"} // $self->DEFAULT_URL
$options->{"search_url"} $self->DEFAULT_URL
Truth table33%1/3
A // B
A= $options->{"search_url"}B= $self->DEFAULT_URL
ABresult
1X1
011
000
19 4 $self->{search_debug} = $options->{search_debug};
20 4 $self->{_next_url} = "$base_url?bus=$native_query";
21 4 $self->user_agent->delay(10/60); # Crawl-Delay: 10 in robots.txt
22 }
23  
24 4 ▶sub _parse_tree {
Subroutine _parse_tree: called CC=8 SCAR=21.9
25 4 my ($self, $tree) = @_;
26 4 my $found = 0;
27  
28 4 my $result_table = $tree->look_down(class => 'mostrar');
29 4 ▶ return unless $result_table;
Branch: 1 branch
BranchTrueFalseTotal
unless $result_table 0 4 4
30 4 my @results = $result_table->find('tbody')->find('tr');
31 4 for (@results) {
32 88 my $result = $self->process_result($_);
33 88 push @{$self->{cache}}, $result;
34 88 ▶ say STDERR 'Title: ', $result->title, ' URL: ', $result->url if $self->{search_debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"search_debug"} 0 88 88
35 88 $found++;
36 }
37  
38 4 my $url = $tree->look_down(rel => 'next');
39 4 ▶ $self->{_next_url} = $self->absurl($self->{_prev_url}, $url->attr('href')) if defined $url;
Branch: 1 branch
BranchTrueFalseTotal
if defined $url 4 0 4
40  
41 4 ▶ say STDERR "Found: $found" if $self->{search_debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"search_debug"} 0 4 4
42 4 ▶ say STDERR 'Next URL: ', $self->{_next_url} if $self->{search_debug} && $self->{_next_url};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"search_debug"} and $self->{"_next_url"} 0 4 4
Condition33%1/3
$self->{"search_debug"} and $self->{"_next_url"}
!ll&&!rl&&r
400
MC/DC0%0/2
$self->{"search_debug"} and $self->{"_next_url"}
$self->{"search_debug"} $self->{"_next_url"}
Truth table33%1/3
A and B
A= $self->{"search_debug"}B= $self->{"_next_url"}
ABresult
0X0
100
111
43 4 $found
44 }
45  
46 2 1;
47 __END__
« Coveralia/Result/Album.pm ↑ Summary Coveralia/Result/Artist.pm »