| 1 | package WWW::GoKGS::Scraper::TournList; | ||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use parent qw/WWW::GoKGS::Scraper/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 15 | ▶ | use WWW::GoKGS::Scraper::Declare; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 16 | ▶ | sub base_uri { 'http://www.gokgs.com/tournList.jsp' } | ||||||||||||||||||||||||||
|
Subroutine
base_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | sub __build_scraper { | ||||||||||||||||||||||||||
|
Subroutine
__build_scraper: called CC=1 SCAR=2.9
| |||||||||||||||||||||||||||||
| 10 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | my %year_index = ( | |||||||||||||||||||||||||||
| 13 | year => 'TEXT', | ||||||||||||||||||||||||||||
| 14 | uri => '@href', | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | my $tournament = scraper { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | process '.', 'name' => [ 'TEXT', sub { s/\s+\([^)]+\)$// } ], | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | 'notes' => [ 'TEXT', sub { m/\s+\(([^)]+)\)$/ && $1 } ]; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | process 'a', 'uri' => '@href'; | |||||||||||||||||||||||||||
| 21 | 1 | }; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | scraper { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 0 | process '//p[a[starts-with(@href,"tournInfo.jsp")]]', | |||||||||||||||||||||||||||
| 25 | 'tournaments[]' => $tournament; | ||||||||||||||||||||||||||||
| 26 | 0 | process '//a[starts-with(@href, "tournList.jsp")]', | |||||||||||||||||||||||||||
| 27 | 'year_index[]' => \%year_index; | ||||||||||||||||||||||||||||
| 28 | 0 | process '//p[preceding-sibling::h2/text()="Year Index"]', | |||||||||||||||||||||||||||
| 29 | '_years' => 'TEXT'; | ||||||||||||||||||||||||||||
| 30 | 1 | }; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub scrape { | ||||||||||||||||||||||||||
|
Subroutine
scrape: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | my $result = $self->SUPER::scrape( @args ); | |||||||||||||||||||||||||||
| 36 | 0 | my $year_index = $result->{year_index}; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my @years = do { | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | my $_years = delete $result->{_years} || q{}; | ||||||||||||||||||||||||||
|
Condition0%0/2
delete $result->{'_years'} || ''
MC/DC0%0/1
delete $result->{'_years'} || ''
delete $result->{'_years'}
Truth table0%0/2
A
A= delete $result->{'_years'}
| |||||||||||||||||||||||||||||
| 40 | 0 | $_years =~ s/ $//; | |||||||||||||||||||||||||||
| 41 | 0 | split / /, $_years; | |||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return $result unless @years; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | for my $i ( 0 .. @years-1 ) { | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | next if $year_index->[$i] and $year_index->[$i]->{year} == $years[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$year_index->[$i] and $year_index->[$i]{"year"} == $years[$i]
MC/DC0%0/2
$year_index->[$i] and $year_index->[$i]{"year"} == $years[$i]
$year_index->[$i]
$year_index->[$i]{"year"} == $years[$i]
Truth table0%0/3
A and B
A= $year_index->[$i]B= $year_index->[$i]{"year"} == $years[$i]
| |||||||||||||||||||||||||||||
| 48 | 0 | splice @$year_index, $i, 0, { year => int $years[$i] }; | |||||||||||||||||||||||||||
| 49 | 0 | last; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | $result; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 15 | 1; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||