Data/Parser/Text.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 97.7% 43 / 44 CC 4 SCAR 5.9
CC
4
Cov
100%
__ANON__
3.0
get_value
2.0
BEGIN
1.0
CRAP 1.8
« Data/Object/Tagline.pm ↑ Summary Data/Object/Category.pm »
1 package Feed::Data::Parser::Text;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 extends 'Feed::Data::Parser::Base';
5 1 ▶use Compiled::Params::OO qw/cpo/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Types::Standard qw/Object HashRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 our $validate;
8 BEGIN {
9 1 ▶ $validate = cpo(
Subroutine BEGIN: called CC=1 SCAR=0.0
10 get_value => [Object, HashRef, Str],
11 );
12 }
13  
14 has '+parser' => (
15 default => sub {
16 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
17 1 my $content = $self->content_ref;
18 1 my (@matches, %match);
19 1 ▶ while ($$content =~ s/([A-Za-z]+)\s*\:(.*)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$content =~ s/([A-Za-z]+)\s*\:(.*)//) 13 1 14
20 13 ▶ if (defined $match{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $match{$1}) 1 12 13
21 1 push @matches, {%match};
22 1 %match = ();
23 }
24 13 $match{$1} = $2;
25 }
26 1 push @matches, {%match};
27 1 return { items => \@matches };
28 },
29 1 );
30  
31 has '+potential_fields' => (
32 default => sub {
33 return {
34 1 ▶ title => 'title',
Subroutine __ANON__: called CC=1 SCAR=0.0
35 description => 'description',
36 date => 'date',
37 author => 'author',
38 category => 'category',
39 permalink => 'permalink',
40 comment => 'comment',
41 link => 'link',
42 content => 'content',
43 image => 'image',
44 };
45 },
46 1 );
47  
48 sub get_value {
49 22 ▶ my ($self, $item, $action) = $validate->get_value->(@_);
Subroutine get_value: called CC=2 SCAR=6.9
Pod undocumented
50 22 my $value = $item->{$action};
51 22 ▶ return $value // '';
Condition100%2/2
$value // ""
l!l
139
MC/DC100%1/1
$value // ""
$value
Truth table100%2/2
A
A= $value
Aresult
11
00
52 }
53  
54 1 1; # End of Data::Feed
« Data/Object/Tagline.pm ↑ Summary Data/Object/Category.pm »