WebSearch/Provider.pm

filter: Statementstmt 87.1% 34 / 39 Branchbran 75.0% 12 / 16 Conditioncond 71.4% 5 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 84.6% 11 / 13 Podpod 88.8% 8 / 9 totaltotal 80.6% 71 / 88 CC 12 SCAR 10.0
CC
12
Cov
82%
tags
6.0
matches
4.0
name
3.0
CRAP 2.7
« WebSearch.pm ↑ Summary
1 package Net::Async::WebSearch::Provider;
2 6 our $VERSION = '0.002';
3 # ABSTRACT: Base class for Net::Async::WebSearch providers
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 Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 33 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
10 33 my $self = bless { %args }, $class;
11 33 ▶ $self->{enabled} = 1 unless defined $self->{enabled};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"enabled"} 33 0 33
12 33 ▶ $self->{tags} ||= [];
Condition100%2/2
$self->{"tags"} ||= []
l!l
627
MC/DC100%1/1
$self->{"tags"} ||= []
$self->{"tags"}
Truth table100%2/2
A
A= $self->{"tags"}
Aresult
11
00
13 33 $self->_init;
14 30 return $self;
15 }
16  
17 ▶sub _init {}
Subroutine _init: called CC=1 SCAR=0.0
18  
19 sub default_name {
20 13 ▶ my ( $self ) = @_;
Subroutine default_name: called CC=1 SCAR=0.0
Pod documented
21 13 my $pkg = ref $self;
22 13 $pkg =~ s/.*:://;
23 13 return lc $pkg;
24 }
25  
26 sub name {
27 273 ▶ my ( $self ) = @_;
Subroutine name: called CC=3 SCAR=11.1
Pod documented
28 273 ▶ @_ > 1 ? ($self->{name} = $_[1]) : ($self->{name} // $self->default_name);
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 1 272 273
Condition66%2/3
$self->{"name"} // $self->default_name
l!l&&r!l&&!r
238340
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 66 ▶sub enabled { @_ > 1 ? ($_[0]->{enabled} = $_[1]) : $_[0]->{enabled} }
Subroutine enabled: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 2 64 66
32  
33 sub tags {
34 0 ▶ my ( $self ) = @_;
Subroutine tags: not called CC=2 SCAR=17.9
Pod documented
35 0 ▶ return @{ $self->{tags} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"tags"} or [] 0 0 0
36 }
37  
38 sub has_tag {
39 47 ▶ my ( $self, $tag ) = @_;
Subroutine has_tag: called CC=2 SCAR=7.0
Pod documented
40 47 ▶ return scalar grep { $_ eq $tag } @{ $self->{tags} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"tags"} or [] 0 47 47
41 }
42  
43 sub matches {
44 72 ▶ my ( $self, $sel ) = @_;
Subroutine matches: called CC=4 SCAR=13.9
Pod documented
45 72 ▶ return 1 if $sel eq $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if $sel eq $self->name 21 51 72
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 sub user_agent_string {
52 17 ▶ 'Net-Async-WebSearch/' . ($Net::Async::WebSearch::VERSION // 'dev');
Subroutine user_agent_string: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
$Net::Async::WebSearch::VERSION // "dev"
l!l
170
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 sub search {
59 0 ▶ my ( $self ) = @_;
Subroutine search: not called CC=1 SCAR=6.9
Pod documented
60 0 croak ref($self).": must implement search()";
61 }
62  
63 6 1;
64  
65 __END__
« WebSearch.pm ↑ Summary