WebSearch/Provider.pm

filter: Statementstmt 87.1% 34 / 39 Branchbran 91.6% 11 / 12 Conditioncond 54.5% 6 / 11 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 84.6% 11 / 13 Podpod 88.8% 8 / 9 totaltotal 78.8% 71 / 90 CC 12 SCAR 10.0
CC
12
Cov
82%
tags
6.0
matches
4.0
name
3.0
CRAP 2.7
« WebSearch/Provider/Marginalia.pm ↑ Summary
1 package Net::Async::WebSearch::Provider;
2 12 our $VERSION = '0.003';
3 # ABSTRACT: Base class for Net::Async::WebSearch providers
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 58 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
9 58 my ( $class, %args ) = @_;
10 58 my $self = bless { %args }, $class;
11 58 ▶ $self->{enabled} = 1 unless defined $self->{enabled};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"enabled"} 58 0 58
12 58 ▶ $self->{tags} ||= [];
Condition100%2/2
$self->{"tags"} ||= []
l!l
652
MC/DC100%1/1
$self->{"tags"} ||= []
$self->{"tags"}
Truth table100%2/2
A
A= $self->{"tags"}
Aresult
11
00
13 58 $self->_init;
14 54 return $self;
15 }
16  
17 14 ▶sub _init {}
Subroutine _init: called CC=1 SCAR=0.0
18  
19 13 ▶sub default_name {
Subroutine default_name: called CC=1 SCAR=0.0
Pod documented
20 13 my ( $self ) = @_;
21 13 my $pkg = ref $self;
22 13 $pkg =~ s/.*:://;
23 13 return lc $pkg;
24 }
25  
26 507 ▶sub name {
Subroutine name: called CC=3 SCAR=11.1
Pod documented
27 507 my ( $self ) = @_;
28 507 ▶ @_ > 1 ? ($self->{name} = $_[1]) : ($self->{name} // $self->default_name);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 1 506 507
Condition66%2/3
$self->{"name"} // $self->default_name
l!l&&r!l&&!r
472340
MC/DC0%0/2
$self->{"name"} // $self->default_name
$self->{"name"} $self->default_name
Truth table66%2/3
A // B
A= $self->{"name"}B= $self->default_name
ABresult
1X1
011
000
29 }
30  
31 67 ▶sub enabled { @_ > 1 ? ($_[0]->{enabled} = $_[1]) : $_[0]->{enabled} }
Subroutine enabled: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 2 65 67
32  
33 0 ▶sub tags {
Subroutine tags: not called CC=2 SCAR=17.9
Pod documented
34 0 my ( $self ) = @_;
35 0 ▶ return @{ $self->{tags} || [] };
Condition0%0/2
$self->{'tags'} || []
l!l
00
MC/DC0%0/1
$self->{'tags'} || []
$self->{'tags'}
Truth table0%0/2
A
A= $self->{'tags'}
Aresult
11
00
36 }
37  
38 47 ▶sub has_tag {
Subroutine has_tag: called CC=2 SCAR=7.0
Pod documented
39 47 my ( $self, $tag ) = @_;
40 47 ▶ return scalar grep { $_ eq $tag } @{ $self->{tags} || [] };
Condition50%1/2
$self->{'tags'} || []
l!l
470
MC/DC0%0/1
$self->{'tags'} || []
$self->{'tags'}
Truth table50%1/2
A
A= $self->{'tags'}
Aresult
11
00
41 }
42  
43 73 ▶sub matches {
Subroutine matches: called CC=4 SCAR=13.9
Pod documented
44 73 my ( $self, $sel ) = @_;
45 73 ▶ return 1 if $sel eq $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if $sel eq $self->name 22 51 73
46 51 ▶ return 1 if $sel eq $self->default_name;
Branch: 1 branch
BranchTrueFalseTotal
if $sel eq $self->default_name 4 47 51
47 47 ▶ return 1 if $self->has_tag($sel);
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_tag($sel) 11 36 47
48 36 return 0;
49 }
50  
51 59 ▶sub user_agent_string {
Subroutine user_agent_string: called CC=2 SCAR=7.6
Pod documented
52 59 ▶ 'Net-Async-WebSearch/' . ($Net::Async::WebSearch::VERSION // 'dev');
Condition50%1/2
$Net::Async::WebSearch::VERSION // "dev"
l!l
590
MC/DC0%0/1
$Net::Async::WebSearch::VERSION // "dev"
$Net::Async::WebSearch::VERSION
Truth table50%1/2
A
A= $Net::Async::WebSearch::VERSION
Aresult
11
00
53 }
54  
55 # Subclasses MUST implement.
56 # Signature: $self->search($http, $query, \%opts)
57 # Returns: Future of arrayref of Net::Async::WebSearch::Result
58 0 ▶sub search {
Subroutine search: not called CC=1 SCAR=6.9
Pod documented
59 0 my ( $self ) = @_;
60 0 croak ref($self).": must implement search()";
61 }
62  
63 12 1;
64  
65 __END__
« WebSearch/Provider/Marginalia.pm ↑ Summary