line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Feed::Data::Parser::CSV; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
673
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
|
|
|
|
|
|
extends 'Feed::Data::Parser::Base'; |
5
|
1
|
|
|
1
|
|
406
|
use Compiled::Params::OO qw/cpo/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
6
|
1
|
|
|
1
|
|
112
|
use Types::Standard qw/Object HashRef Str/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
7
|
1
|
|
|
1
|
|
951
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
156
|
use Text::CSV_XS qw/csv/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
84
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $validate; |
11
|
|
|
|
|
|
|
BEGIN { |
12
|
1
|
|
|
1
|
|
8
|
$validate = cpo( |
13
|
|
|
|
|
|
|
get_value => [Object, HashRef, Str], |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '+parser' => ( |
18
|
|
|
|
|
|
|
default => sub { |
19
|
|
|
|
|
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
my $content = $self->content_ref; |
21
|
|
|
|
|
|
|
return { items => csv(in => $content, headers => "auto") }; |
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
|
48
|
my ($self, $item, $action) = $validate->get_value->(@_); |
44
|
22
|
|
|
|
|
207
|
my $value = $item->{$action}; |
45
|
22
|
|
100
|
|
|
81
|
return $value // ''; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; # End of Data::Feed |