File Coverage

blib/lib/NewsExtractor/SiteSpecificExtractor/newtalk_tw.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 25 48.0


line stmt bran cond sub pod time code
1             package NewsExtractor::SiteSpecificExtractor::newtalk_tw;
2 1     1   8 use utf8;
  1         3  
  1         6  
3 1     1   34 use Moo;
  1         3  
  1         5  
4             extends 'NewsExtractor::GenericExtractor';
5              
6 1     1   319 use Importer 'NewsExtractor::TextUtil' => 'u';
  1         3  
  1         6  
7              
8             sub dateline {
9 0     0 0   my ($self) = @_;
10 0           my ($el, $dateline);
11 0 0         if ($el = $self->dom->at('meta[property="article:published_time"]')) {
    0          
12 0           $dateline = $el->attr('content');
13             } elsif ($el = $self->dom->at('div.contentBox div.content_date')) {
14 0           my @t = $el->all_text =~ m/([0-9]+)/g;
15 0           $dateline = u(sprintf('%04d-%02d-%02dT%02d:%02d:%02d+08:00',
16             $t[0], $t[1], $t[2], $t[3], $t[4], 59));
17             }
18 0           return $dateline;
19             }
20              
21             1;