Crawl4AI/Attempt.pm

filter: Statementstmt 80.9% 17 / 21 Branchbran 62.5% 5 / 8 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 50.0% 3 / 6 Podpod 100% 2 / 2 totaltotal 68.8% 31 / 45 CC 7 SCAR 17.7
CC
7
Cov
74%
to_hash
9.2
TO_JSON
2.0
__ANON__
1.1
CRAP 5.9
« Crawl4AI/DeepCrawlIterator.pm ↑ Summary Crawl4AI.pm »
1 package WWW::Crawl4AI::Attempt;
2 # ABSTRACT: one strategy attempt in a WWW::Crawl4AI fallback chain
3 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 our $VERSION = '0.001';
6  
7  
8 6 has backend => ( is => 'ro', required => 1 );
9  
10  
11 0 ▶has cost_class => ( is => 'ro', default => sub { 'cheap' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
12  
13  
14 0 ▶has ok => ( is => 'ro', default => sub { 0 } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
15  
16  
17 6 has page => ( is => 'ro' );
18  
19  
20 3 ▶has signals => ( is => 'ro', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22  
23 6 has why_failed => ( is => 'ro' );
24  
25  
26 6 has error => ( is => 'ro' );
27  
28  
29 6 has elapsed => ( is => 'ro' );
30  
31  
32 5 ▶sub to_hash {
Subroutine to_hash: called CC=7 SCAR=22.1
Pod documented
33 5 my ( $self ) = @_;
34 5 ▶ my $page = $self->page || {};
Condition50%1/2
$self->page || {}
l!l
50
MC/DC0%0/1
$self->page || {}
$self->page
Truth table50%1/2
A
A= $self->page
Aresult
11
00
35 return {
36 backend => $self->backend,
37 cost_class => $self->cost_class,
38 ok => $self->ok ? \1 : \0,
39 status_code => $page->{status_code},
40 final_url => $page->{final_url} // $page->{url},
41 5 ▶ markdown_len => defined $page->{markdown} ? length $page->{markdown} : 0,
Branch: 3 branches
BranchTrueFalseTotal
$self->ok ? : 2 3 5
defined $page->{'markdown'} ? : 5 0 5
defined $self->error ? : 0 5 5
Condition66%2/3
$page->{"final_url"} // $page->{"url"}
l!l&&r!l&&!r
203
MC/DC50%1/2
$page->{"final_url"} // $page->{"url"}
$page->{"final_url"} $page->{"url"}
Truth table66%2/3
A // B
A= $page->{"final_url"}B= $page->{"url"}
ABresult
1X1
011
000
42 signals => $self->signals,
43 why_failed => $self->why_failed,
44 0 ▶ ( defined $self->error ? ( error => "@{[ $self->error ]}" ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
defined $self->elapsed ? : 5 0 5
45 ( defined $self->elapsed ? ( elapsed => $self->elapsed ) : () ),
46 };
47 }
48  
49  
50 0 ▶sub TO_JSON { $_[0]->to_hash }
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod documented
51  
52  
53 6 1;
54  
55 __END__
« Crawl4AI/DeepCrawlIterator.pm ↑ Summary Crawl4AI.pm »