| 1 | package Net::Async::WebSearch::Result; | ||||||||||||||||||||||||||||||||||||||
| 2 | 6 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Single web search result record | ||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 9 | 88 | ▶ | my ( $class, %args ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 10 | my $self = { | ||||||||||||||||||||||||||||||||||||||
| 11 | url => $args{url}, | ||||||||||||||||||||||||||||||||||||||
| 12 | title => $args{title}, | ||||||||||||||||||||||||||||||||||||||
| 13 | snippet => $args{snippet}, | ||||||||||||||||||||||||||||||||||||||
| 14 | provider => $args{provider}, | ||||||||||||||||||||||||||||||||||||||
| 15 | rank => $args{rank}, | ||||||||||||||||||||||||||||||||||||||
| 16 | score => $args{score}, | ||||||||||||||||||||||||||||||||||||||
| 17 | published_at => $args{published_at}, | ||||||||||||||||||||||||||||||||||||||
| 18 | language => $args{language}, | ||||||||||||||||||||||||||||||||||||||
| 19 | nsfw => $args{nsfw}, | ||||||||||||||||||||||||||||||||||||||
| 20 | domain => $args{domain}, | ||||||||||||||||||||||||||||||||||||||
| 21 | fetched => $args{fetched}, | ||||||||||||||||||||||||||||||||||||||
| 22 | raw => $args{raw}, | ||||||||||||||||||||||||||||||||||||||
| 23 | extra => $args{extra} || {}, | ||||||||||||||||||||||||||||||||||||||
| 24 | 88 | ▶ | }; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'extra'} || {}
MC/DC100%1/1
$args{'extra'} || {}
$args{'extra'}
Truth table100%2/2
A
A= $args{'extra'}
| |||||||||||||||||||||||||||||||||||||||
| 25 | 88 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||
| 26 | # Auto-derive domain from URL if not supplied. | ||||||||||||||||||||||||||||||||||||||
| 27 | 88 | ▶ | if ( !defined $self->{domain} && defined $self->{url} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $self->{"domain"} and defined $self->{"url"}
MC/DC0%0/2
not defined $self->{"domain"} and defined $self->{"url"}
not defined $self->{"domain"}
defined $self->{"url"}
Truth table33%1/3
not(A) and B
A= not defined $self->{"domain"}B= defined $self->{"url"}
| |||||||||||||||||||||||||||||||||||||||
| 28 | 88 | my $u = eval { URI->new( $self->{url} ) }; | |||||||||||||||||||||||||||||||||||||
| 29 | 88 | ▶ | if ( $u && $u->can('host') ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$u and $u->can("host")
MC/DC0%0/2
$u and $u->can("host")
$u
$u->can("host")
Truth table33%1/3
A and B
A= $uB= $u->can("host")
| |||||||||||||||||||||||||||||||||||||||
| 30 | 88 | my $h = eval { $u->host }; | |||||||||||||||||||||||||||||||||||||
| 31 | 88 | ▶ | $self->{domain} = $h if defined $h && length $h; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $h and length $h
MC/DC0%0/2
defined $h and length $h
defined $h
length $h
Truth table33%1/3
A and B
A= defined $hB= length $h
| |||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||
| 34 | 88 | return $self; | |||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||
| 37 | 112 | ▶ | sub url { $_[0]->{url} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub title { $_[0]->{title} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 39 | 80 | ▶ | sub snippet { $_[0]->{snippet} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
snippet: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 40 | 91 | ▶ | sub provider { $_[0]->{provider} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 41 | 140 | ▶ | sub rank { @_ > 1 ? ($_[0]->{rank} = $_[1]) : $_[0]->{rank} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
rank: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 42 | 64 | ▶ | sub score { @_ > 1 ? ($_[0]->{score} = $_[1]) : $_[0]->{score} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
score: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub published_at { $_[0]->{published_at} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
published_at: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub language { $_[0]->{language} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
language: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub nsfw { $_[0]->{nsfw} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
nsfw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub domain { $_[0]->{domain} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
domain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 47 | 52 | ▶ | sub fetched { @_ > 1 ? ($_[0]->{fetched} = $_[1]) : $_[0]->{fetched} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
fetched: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub raw { $_[0]->{raw} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 49 | 67 | ▶ | sub extra { $_[0]->{extra} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
extra: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | sub to_hash { | ||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
to_hash: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 53 | return { | ||||||||||||||||||||||||||||||||||||||
| 54 | url => $self->{url}, | ||||||||||||||||||||||||||||||||||||||
| 55 | title => $self->{title}, | ||||||||||||||||||||||||||||||||||||||
| 56 | snippet => $self->{snippet}, | ||||||||||||||||||||||||||||||||||||||
| 57 | provider => $self->{provider}, | ||||||||||||||||||||||||||||||||||||||
| 58 | rank => $self->{rank}, | ||||||||||||||||||||||||||||||||||||||
| 59 | score => $self->{score}, | ||||||||||||||||||||||||||||||||||||||
| 60 | ( defined $self->{published_at} ? ( published_at => $self->{published_at} ) : () ), | ||||||||||||||||||||||||||||||||||||||
| 61 | ( defined $self->{language} ? ( language => $self->{language} ) : () ), | ||||||||||||||||||||||||||||||||||||||
| 62 | ( defined $self->{nsfw} ? ( nsfw => $self->{nsfw} ? 1 : 0 ) : () ), | ||||||||||||||||||||||||||||||||||||||
| 63 | ( defined $self->{domain} ? ( domain => $self->{domain} ) : () ), | ||||||||||||||||||||||||||||||||||||||
| 64 | ( defined $self->{fetched} ? ( fetched => $self->{fetched} ) : () ), | ||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | ( %{ $self->{extra} || {} } ? ( extra => $self->{extra} ) : () ), | ||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | 6 | 1; | |||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||||||||||||||||