| 1 | package WWW::GoKGS::Scraper; | ||||||||||||||||||||
| 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 Carp qw/croak/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 15 | ▶ | use URI; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 0 | ▶ | sub base_uri { | ||||||||||||||||||
|
Subroutine
base_uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 8 | 0 | croak 'call to abstract method ', __PACKAGE__, '::base_uri'; | |||||||||||||||||||
| 9 | } | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 112 | ▶ | sub build_uri { | ||||||||||||||||||
|
Subroutine
build_uri: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 12 | 112 | my ( $class, @query ) = @_; | |||||||||||||||||||
| 13 | 112 | my $uri = URI->new( $class->base_uri ); | |||||||||||||||||||
| 14 | 112 | ▶ | $uri->query_form( @query ) if @query; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 112 | $uri; | |||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 7 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 19 | 7 | my $class = shift; | |||||||||||||||||||
| 20 | 0 | ▶ | my %args = @_ == 1 ? %{$_[0]} : @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 7 | my $self = bless {}, $class; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 7 | $self->init( \%args ); | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 7 | $self; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 7 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||
| 29 | 7 | my ( $self, $args ) = @_; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 7 | for my $method (qw/user_agent _tree_builder_class/) { | |||||||||||||||||||
| 32 | 14 | ▶ | $self->$method( $args->{$method} ) if exists $args->{$method}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 7 | return; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 14 | ▶ | sub _scraper { | ||||||||||||||||||
|
Subroutine
_scraper: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 39 | 14 | my $self = shift; | |||||||||||||||||||
| 40 | 14 | ▶ | $self->{_scraper} ||= $self->__build_scraper; | ||||||||||||||||||
|
Condition66%2/3
$self->{"_scraper"} ||= $self->__build_scraper
MC/DC0%0/2
$self->{"_scraper"} ||= $self->__build_scraper
$self->{"_scraper"}
$self->__build_scraper
Truth table66%2/3
A ||= B
A= $self->{"_scraper"}B= $self->__build_scraper
| |||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub __build_scraper { | ||||||||||||||||||
|
Subroutine
__build_scraper: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 44 | 0 | croak 'call to abstract method ', __PACKAGE__, '::__build_scraper'; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 7 | ▶ | sub _tree_builder_class { | ||||||||||||||||||
|
Subroutine
_tree_builder_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 48 | 7 | my ( $self, @args ) = @_; | |||||||||||||||||||
| 49 | 7 | $self->_scraper->_tree_builder_class( @args ); | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 7 | ▶ | sub user_agent { | ||||||||||||||||||
|
Subroutine
user_agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 53 | 7 | my ( $self, @args ) = @_; | |||||||||||||||||||
| 54 | 7 | $self->_scraper->user_agent( @args ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | ▶ | sub scrape { | ||||||||||||||||||
|
Subroutine
scrape: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 58 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||
| 59 | 0 | $self->_scraper->scrape( @args ); | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub query { | ||||||||||||||||||
|
Subroutine
query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 63 | 0 | my ( $self, @query ) = @_; | |||||||||||||||||||
| 64 | 0 | $self->scrape( ref($self)->build_uri(@query) ); | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 15 | 1; | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||