line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86495
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
7
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
8
|
1
|
|
|
1
|
|
651
|
use Catmandu; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
9
|
1
|
|
|
1
|
|
377
|
use namespace::clean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
197
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
627
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has name => (fix_arg => 1); |
16
|
|
|
|
|
|
|
has opts => (fix_opt => 'collect'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
my $name = $self->name; |
20
|
6
|
|
|
6
|
|
48
|
my $opts = $self->opts; |
21
|
6
|
|
|
|
|
14
|
as_path($self->path) |
22
|
6
|
|
|
|
|
42
|
->updater( |
23
|
|
|
|
|
|
|
if_string => sub {Catmandu->import_from_string($_[0], $name, %$opts)} |
24
|
|
|
|
|
|
|
); |
25
|
6
|
|
|
6
|
|
37
|
} |
26
|
6
|
|
|
|
|
24
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=encoding utf8 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Catmandu::Fix::import_from_string - Import data from a string into an array ref, using a named importer. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#BEFORE: { 'json' => '[{"name":"Nicolas"}]' } |
41
|
|
|
|
|
|
|
#AFTER: { 'json' => [{"name":"Nicolas"}] } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
import_from_string('json','JSON') |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#BEFORE: { record => qq(first_name;name\nNicolas;Franck\nPatrick;Hochstenbach\n) } |
46
|
|
|
|
|
|
|
#AFTER: { record => [{ "first_name" => "Nicolas",name => "Franck" },{ "first_name" => "Patrick",name => "Hochstenbach" }] } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
import_from_string('record','CSV', 'sep_char' => ';') |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 import_from_string( PATH, NAME [, IMPORT_OPTIONS ] ) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This fix uses the function import_from_string of the package L<Catmandu>, but requires the NAME of the importer. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
It always returns an array of hashes. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over 4 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item PATH |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
name of the importer to use. As usual in Catmandu, one can choose: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
* full package name of the importer (e.g. 'Catmandu::Importer::JSON') |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
* short package name of the importer (e.g. 'JSON') |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
* name of the importer as declared in the Catmandu configuration |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item IMPORT_OPTIONS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
extra options for the named importer |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Nicolas Franck, C<< <nicolas.franck at ugent.be> >> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
L<Catmandu::Fix>, L<Catmandu::Importer> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |