Data/Parser/Meta.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 5 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 46 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
get_value
2.0
BEGIN
2.0
CRAP 2.0
1 package Feed::Data::Parser::Meta;
2  
3 use Moo;
4 extends 'Feed::Data::Parser::Base';
5 use Compiled::Params::OO qw/cpo/;
6 use Types::Standard qw/Object HashRef Str/;
7  
8 our $validate;
9 BEGIN {
10 $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 my ($self, $item, $action) = $validate->get_value->(@_);
36 my $value = $item->{$action};
37 return $value // '';
38 }
39  
40 1; # End of Feed::Data