line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Feed::Data::Parser::Text; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
623
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
extends 'Feed::Data::Parser::Base'; |
5
|
1
|
|
|
1
|
|
417
|
use Compiled::Params::OO qw/cpo/; |
|
1
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
16
|
|
6
|
1
|
|
|
1
|
|
107
|
use Types::Standard qw/Object HashRef Str/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
our $validate; |
8
|
|
|
|
|
|
|
BEGIN { |
9
|
1
|
|
|
1
|
|
1061
|
$validate = cpo( |
10
|
|
|
|
|
|
|
get_value => [Object, HashRef, Str], |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has '+parser' => ( |
15
|
|
|
|
|
|
|
default => sub { |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
my $content = $self->content_ref; |
18
|
|
|
|
|
|
|
my (@matches, %match); |
19
|
|
|
|
|
|
|
while ($$content =~ s/([A-Za-z]+)\s*\:(.*)//) { |
20
|
|
|
|
|
|
|
if (defined $match{$1}) { |
21
|
|
|
|
|
|
|
push @matches, {%match}; |
22
|
|
|
|
|
|
|
%match = (); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
$match{$1} = $2; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
push @matches, {%match}; |
27
|
|
|
|
|
|
|
return { items => \@matches }; |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has '+potential_fields' => ( |
32
|
|
|
|
|
|
|
default => sub { |
33
|
|
|
|
|
|
|
return { |
34
|
|
|
|
|
|
|
title => 'title', |
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
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_value { |
49
|
22
|
|
|
22
|
0
|
47
|
my ($self, $item, $action) = $validate->get_value->(@_); |
50
|
22
|
|
|
|
|
210
|
my $value = $item->{$action}; |
51
|
22
|
|
100
|
|
|
85
|
return $value // ''; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; # End of Data::Feed |