NewsExtractor/Download.pm

filter: Statementstmt 55.5% 25 / 45 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 72.7% 8 / 11 Podpod 0.0% 0 / 1 totaltotal 48.5% 33 / 68 CC 7 SCAR 24.4
CC
7
Cov
46%
__ANON__
30.0
__ANON__
12.0
parse
2.0
CRAP 11.5
« NewsExtractor/SiteSpecificExtractor/www_ustv_com_tw.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/www_hkcnews_com.pm »
1 package NewsExtractor::Download;
2 1 ▶use v5.18;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Types::Standard qw< InstanceOf >;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 has tx => ( required => 1, is => 'ro', isa => InstanceOf['Mojo::Transaction::HTTP']);
7  
8 1 ▶use NewsExtractor::Article;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use NewsExtractor::Extractor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use NewsExtractor::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Importer 'NewsExtractor::TextUtil' => qw(u is_empty);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my $self = $_[0];
17 0 my ($err, $o, %article);
18  
19 0 ▶ try {
Subroutine __ANON__: not called CC=5 SCAR=34.0
20 0 my $x = NewsExtractor::Extractor->new( tx => $self->tx );
21 0 $article{headline} = $x->headline;
22 0 $article{article_body} = $x->content_text;
23  
24 0 for my $it (qw(dateline journalist)) {
25 0 my $v = $x->$it;
26 0 ▶ if (defined($v)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) 0 0 0
27 0 $article{$it} = $v;
28 }
29 }
30  
31 0 for my $it (qw(headline article_body)) {
32 0 ▶ if (is_empty($article{$it})) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_empty($article{$it})) 0 0 0
33 0 $err = NewsExtractor::Error->new(
34 message => u("Failed to extract: $it")
35 );
36 0 last;
37 }
38 }
39  
40 0 $o = NewsExtractor::Article->new(%article);
41 0 ▶ } catch {
Subroutine __ANON__: not called CC=3 SCAR=24.8
42 0 my $e = $_;
43  
44 0 ▶ if (ref($e) && $e->isa('Error::TypeTiny::Assertion')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e and $e->isa("Error::TypeTiny::Assertion")) 0 0 0
Condition0%0/3
ref $e and $e->isa("Error::TypeTiny::Assertion")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $e and $e->isa("Error::TypeTiny::Assertion")
ref $e $e->isa("Error::TypeTiny::Assertion")
Truth table0%0/3
A and B
A= ref $eB= $e->isa("Error::TypeTiny::Assertion")
ABresult
0X0
100
111
45 0 $e = $e->message;
46 }
47  
48 0 $err = NewsExtractor::Error->new(
49 message => u($e),
50 debug => { articleArgs => \%article },
51 );
52 0 };
53  
54 0 return ($err, $o);
55 }
56  
57 1 1;
« NewsExtractor/SiteSpecificExtractor/www_ustv_com_tw.pm ↑ Summary NewsExtractor/SiteSpecificExtractor/www_hkcnews_com.pm »