NewsExtractor/SiteSpecificExtractor/news_ebc_net_tw.pm

filter: Statementstmt 44.0% 11 / 25 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 2 totaltotal 35.0% 14 / 40 CC 4 SCAR 14.1
CC
4
Cov
35%
__ANON__
6.0
journalist
6.0
dateline
6.0
CRAP 4.1
« NewsExtractor/SiteSpecificExtractor/news_pts_org_tw.pm ↑ Summary NewsExtractor/TextUtil.pm »
1 package NewsExtractor::SiteSpecificExtractor::news_ebc_net_tw;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 extends 'NewsExtractor::GenericExtractor';
5  
6 1 ▶use Importer 'NewsExtractor::TextUtil' => 'reformat_dateline';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub _build_content_text {
Subroutine _build_content_text: not called CC=1 SCAR=6.9
9 0 my ($self) = @_;
10  
11 # Remove the in-article ad.
12 $self->dom->find("div.raw-style > content-ad > p")->grep(
13 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
14 0 ▶ ($_->child_nodes->size > 2)
Branch: 1 branch
BranchTrueFalseTotal
$_->child_nodes->size > 2 and $_->children("a")->size >= 2 0 0 0
15 && ($_->children("a")->size >= 2)
16 }
17 0 )->map('remove');
18  
19 0 my $text = $self->SUPER::_build_content_text();
20  
21 0 $text =~ s/\n\n【往下看更多】.+\z//s;
22  
23 0 return $text;
24 }
25  
26 0 ▶sub journalist {
Subroutine journalist: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my ($self) = @_;
28 0 ▶ my $guess = $self->dom->at('.fncnews-content > .info > span.small-gray-text') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $guess = $self->dom->at(".fncnews-content > .info > span.small-gray-text") or return 0 0 0
29 0 my $text = $guess->all_text;
30 0 my ($name) = $text =~ m/(?:東森新聞(?:\s*責任編輯)?)\s+(.+)$/;
31 0 return $name;
32 }
33  
34 0 ▶sub dateline {
Subroutine dateline: not called CC=2 SCAR=17.9
Pod undocumented
35 0 my ($self) = @_;
36 0 ▶ my $el = $self->dom->at(".fncnews-content > .info > span.small-gray-text") or return;
Branch: 1 branch
BranchTrueFalseTotal
my $el = $self->dom->at(".fncnews-content > .info > span.small-gray-text") or return 0 0 0
37 0 return reformat_dateline($el->all_text(), '+08:00');
38 }
39  
40 1 1;
« NewsExtractor/SiteSpecificExtractor/news_pts_org_tw.pm ↑ Summary NewsExtractor/TextUtil.pm »