File Coverage

blib/lib/NewsExtractor/SiteSpecificExtractor/UDN.pm
Criterion Covered Total %
statement 9 33 27.2
branch 0 10 0.0
condition n/a
subroutine 3 8 37.5
pod 0 4 0.0
total 12 55 21.8


line stmt bran cond sub pod time code
1             use utf8;
2 1     1   6 use Moo;
  1         2  
  1         5  
3 1     1   27 extends 'NewsExtractor::SiteSpecificExtractor';
  1         2  
  1         5  
4              
5             use Importer 'NewsExtractor::TextUtil' => qw( html2text normalize_whitespace reformat_dateline );
6 1     1   274  
  1         2  
  1         6  
7             my ($self) = @_;
8             my $el = $self->dom->at('#story_art_title, h1.story_art_title, h1.article-content__title') or return;
9 0     0 0   my $txt = $el->all_text;
10 0 0         return normalize_whitespace($txt);
11 0           }
12 0            
13             my ($self) = @_;
14             my $el;
15             if ($el = $self->dom->at(".shareBar__info--author > span:nth-child(1), .authors time.article-content__time")) {
16 0     0 0   my $txt = $el->all_text;
17 0           return normalize_whitespace($txt);
18 0 0         }
19 0            
20 0           # opinion.udn.com
21             if ($el = $self->dom->at('.story_bady_info > time[datetime]')) {
22             return reformat_dateline($el->all_text, '+08:00');
23             }
24 0 0         }
25 0            
26             my ($self) = @_;
27             my $el;
28             if ($el = $self->dom->at(".shareBar__info--author, .authors span.article-content__author")) {
29             my $txt = $el->all_text;
30 0     0 0   $txt =~ s/\s+/ /g; # Sometimes there are newlines
31 0           return normalize_whitespace($txt);
32 0 0         }
33 0            
34 0           # opinion.udn.com
35 0           if ($el = $self->dom->at('.story_bady_info')) {
36             return $el->find('a.author')->map(sub { normalize_whitespace( $_->text ) })->join(', ') . "";
37             }
38             }
39 0 0          
40 0     0     my ($self) = @_;
  0            
41             my $el = $self->dom->at("section.article-content__editor");
42             $el->find("script, style")->map("remove");
43             return html2text("$el");
44             }
45 0     0 0    
46 0           1;