line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Feed::Data::Parser::Meta; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1363
|
use Moo; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
extends 'Feed::Data::Parser::Base'; |
5
|
2
|
|
|
2
|
|
914
|
use Compiled::Params::OO qw/cpo/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
28
|
|
6
|
2
|
|
|
2
|
|
225
|
use Types::Standard qw/Object HashRef Str/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $validate; |
9
|
|
|
|
|
|
|
BEGIN { |
10
|
2
|
|
|
2
|
|
2048
|
$validate = cpo( |
11
|
|
|
|
|
|
|
get_value => [Object, HashRef, Str], |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+parser' => ( |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
my $content = $self->content_ref; |
19
|
|
|
|
|
|
|
my %match; |
20
|
|
|
|
|
|
|
while ($$content =~ s/\<meta(.*)\/\>//) { |
21
|
|
|
|
|
|
|
my $match = $1; |
22
|
|
|
|
|
|
|
$match =~ m/(name|property)\=\"([^"]+)/xms; |
23
|
|
|
|
|
|
|
my $name = [split ":", $2]->[1]; |
24
|
|
|
|
|
|
|
$match =~ m/content\=\"([^"]+)/xms; |
25
|
|
|
|
|
|
|
my $value = $1; |
26
|
|
|
|
|
|
|
$match{$name} = $value unless $match{$name}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
$match{link} = $match{url}; |
29
|
|
|
|
|
|
|
$match{author} = $match{site_name} || $match{site}; |
30
|
|
|
|
|
|
|
return { items => [\%match] }; |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_value { |
35
|
20
|
|
|
20
|
0
|
60
|
my ($self, $item, $action) = $validate->get_value->(@_); |
36
|
20
|
|
|
|
|
196
|
my $value = $item->{$action}; |
37
|
20
|
|
100
|
|
|
87
|
return $value // ''; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; # End of Feed::Data |