| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Feed::Data::Parser::JSON; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
678
|
use Moo; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
|
|
extends 'Feed::Data::Parser::Base'; |
|
5
|
1
|
|
|
1
|
|
470
|
use Compiled::Params::OO qw/cpo/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
18
|
|
|
6
|
1
|
|
|
1
|
|
115
|
use Types::Standard qw/Object HashRef Str/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
7
|
1
|
|
|
1
|
|
1081
|
use JSON; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $validate; |
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
1
|
|
|
1
|
|
214
|
$validate = cpo( |
|
12
|
|
|
|
|
|
|
get_value => [Object, HashRef, Str], |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '+parser' => ( |
|
17
|
|
|
|
|
|
|
default => sub { |
|
18
|
|
|
|
|
|
|
my $self = shift; |
|
19
|
|
|
|
|
|
|
my $content = $self->content_ref; |
|
20
|
|
|
|
|
|
|
my $matches = JSON->new->decode($$content); |
|
21
|
|
|
|
|
|
|
return { items => $matches }; |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has '+potential_fields' => ( |
|
26
|
|
|
|
|
|
|
default => sub { |
|
27
|
|
|
|
|
|
|
return { |
|
28
|
|
|
|
|
|
|
title => 'title', |
|
29
|
|
|
|
|
|
|
description => 'description', |
|
30
|
|
|
|
|
|
|
date => 'date', |
|
31
|
|
|
|
|
|
|
author => 'author', |
|
32
|
|
|
|
|
|
|
category => 'category', |
|
33
|
|
|
|
|
|
|
permalink => 'permalink', |
|
34
|
|
|
|
|
|
|
comment => 'comment', |
|
35
|
|
|
|
|
|
|
link => 'link', |
|
36
|
|
|
|
|
|
|
content => 'content', |
|
37
|
|
|
|
|
|
|
image => 'image', |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
}, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub get_value { |
|
43
|
22
|
|
|
22
|
0
|
54
|
my ($self, $item, $action) = $validate->get_value->(@_); |
|
44
|
22
|
|
|
|
|
236
|
my $value = $item->{$action}; |
|
45
|
22
|
|
100
|
|
|
82
|
return $value // ''; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; # End of Data::Feed |