Data/Parser/Meta.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 89.8% 44 / 49 CC 5 SCAR 8.8
CC
5
Cov
95%
__ANON__
4.0
get_value
2.0
BEGIN
1.0
CRAP 2.4
« Data/Parser/RSS.pm ↑ Summary Data/Object.pm »
1 package Feed::Data::Parser::Meta;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'Feed::Data::Parser::Base';
5 2 ▶use Compiled::Params::OO qw/cpo/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Types::Standard qw/Object HashRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $validate;
9 BEGIN {
10 2 ▶ $validate = cpo(
Subroutine BEGIN: called CC=1 SCAR=0.0
11 get_value => [Object, HashRef, Str],
12 );
13 }
14  
15 has '+parser' => (
16 default => sub {
17 2 ▶ my $self = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
18 2 my $content = $self->content_ref;
19 2 my %match;
20 2 ▶ while ($$content =~ s/\<meta(.*)\/\>//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$content =~ s[\<meta(.*)/\>][]) 24 2 26
21 24 my $match = $1;
22 24 $match =~ m/(name|property)\=\"([^"]+)/xms;
23 24 my $name = [split ":", $2]->[1];
24 24 $match =~ m/content\=\"([^"]+)/xms;
25 24 my $value = $1;
26 24 ▶ $match{$name} = $value unless $match{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $match{$name} 18 6 24
27 }
28 2 $match{link} = $match{url};
29 2 ▶ $match{author} = $match{site_name} || $match{site};
Condition33%1/3
$match{'site_name'} || $match{'site'}
l!l&&r!l&&!r
200
MC/DC0%0/2
$match{'site_name'} || $match{'site'}
$match{'site_name'} $match{'site'}
Truth table33%1/3
A || B
A= $match{'site_name'}B= $match{'site'}
ABresult
1X1
011
000
30 2 return { items => [\%match] };
31 },
32 2 );
33  
34 sub get_value {
35 20 ▶ my ($self, $item, $action) = $validate->get_value->(@_);
Subroutine get_value: called CC=2 SCAR=6.9
Pod undocumented
36 20 my $value = $item->{$action};
37 20 ▶ return $value // '';
Condition100%2/2
$value // ""
l!l
1010
MC/DC100%1/1
$value // ""
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
38 }
39  
40 2 1; # End of Feed::Data
« Data/Parser/RSS.pm ↑ Summary Data/Object.pm »