Coveralia/Result/Album.pm

filter: Statementstmt 51.7% 30 / 58 Branchbran 6.2% 1 / 16 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 69.2% 9 / 13 Podpod 100% 7 / 7 totaltotal 47.0% 47 / 100 CC 12 SCAR 32.6
CC
12
Cov
40%
parse_page
72.0
covers
6.0
cover
6.0
CRAP 26.0
↑ Summary Coveralia.pm »
1 package WWW::Search::Coveralia::Result::Album;
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::SearchResult/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.001';
9  
10 2 ▶use HTML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use PerlX::Maybe;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 55 ▶sub artist { shift->_elem(artist => @_) }
Subroutine artist: called CC=1 SCAR=0.0
Pod documented
14 44 ▶sub year { shift->_elem(year => @_) }
Subroutine year: called CC=1 SCAR=0.0
Pod documented
15  
16 44 ▶sub new{
Subroutine new: called CC=2 SCAR=6.9
Pod documented
17 44 my ($class, $obj, $url, $title, $artist, $year, $covers) = @_;
18 44 my $self = $class->SUPER::new;
19 44 $self->{obj} = $obj;
20 44 ▶ $self->{covers} = $covers if $covers;
Branch: 1 branch
BranchTrueFalseTotal
if $covers 0 44 44
21  
22 44 $self->title($title);
23 44 $self->artist($artist);
24 44 $self->year($year);
25 44 $self->add_url($url);
26 44 $self
27 }
28  
29 0 ▶sub parse_page{
Subroutine parse_page: not called CC=8 SCAR=42.8
Pod documented
30 0 my ($self) = @_;
31 0 my $tree = HTML::TreeBuilder->new_from_url($self->url);
32 0 my $cover_list = $tree->look_down(class => 'lista_normal');
33 0 ▶ my @covers = grep { ($_->find('img')->attr('class') // '') ne 'sprites_enviax' } $cover_list->find('a');
Condition0%0/2
$_->find("img")->attr("class") // ""
l!l
00
MC/DC0%0/1
$_->find("img")->attr("class") // ""
$_->find("img")->attr("class")
Truth table0%0/2
A
A= $_->find("img")->attr("class")
Aresult
11
00
34 0 $self->{covers} = {map {lc $_->as_text => $self->{obj}->absurl('', $_->attr('href'))} @covers};
35 0 my @songs = $tree->look_down(id => 'pagina_disco_lista')->find('tr');
36 $self->{songs} = [map {
37 0 my ($nr, $title, @extra) = $_->find('td');
38 0 my %ret = (id => $nr->as_text, name => $title->as_text);
39 0 for (@extra) {
40 0 ▶ next if ($_->attr('class') // '') eq 'letrano';
Branch: 1 branch
BranchTrueFalseTotal
if ($_->attr("class") // "") eq "letrano" 0 0 0
Condition0%0/2
$_->attr("class") // ""
l!l
00
MC/DC0%0/1
$_->attr("class") // ""
$_->attr("class")
Truth table0%0/2
A
A= $_->attr("class")
Aresult
11
00
41 0 ▶ $ret{lyrics} = $self->{obj}->absurl('', $_->find('a')->attr('href')) if $_->as_text =~ /letra/i;
Branch: 1 branch
BranchTrueFalseTotal
if $_->as_text =~ /letra/iu 0 0 0
42 0 ▶ $ret{video} = $self->{obj}->absurl('', $_->find('a')->attr('href')) if $_->as_text =~ /video/i;
Branch: 1 branch
BranchTrueFalseTotal
if $_->as_text =~ /video/iu 0 0 0
43 0 ▶ $ret{tab} = $self->{obj}->absurl('', $_->find('a')->attr('href')) if $_->as_text =~ /acorde/i;
Branch: 1 branch
BranchTrueFalseTotal
if $_->as_text =~ /acorde/iu 0 0 0
44 }
45 0 \%ret
46 } @songs]
47 }
48  
49 0 ▶sub covers{
Subroutine covers: not called CC=2 SCAR=17.9
Pod documented
50 0 my ($self) = @_;
51 0 ▶ $self->parse_page unless $self->{covers};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"covers"} 0 0 0
52 0 %{$self->{covers}}
53 }
54  
55 0 ▶sub cover{
Subroutine cover: not called CC=2 SCAR=17.9
Pod documented
56 0 my ($self, $cover) = @_;
57 0 ▶ $self->parse_page unless $self->{covers};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"covers"} 0 0 0
58 0 $self->{covers}{$cover}
59 }
60  
61 0 ▶sub songs{
Subroutine songs: not called CC=2 SCAR=17.9
Pod documented
62 0 my ($self) = @_;
63 0 ▶ $self->parse_page unless $self->{songs};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"songs"} 0 0 0
64 0 @{$self->{songs}}
65 }
66  
67 2 1;
68 __END__
↑ Summary Coveralia.pm »