line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::export_to_string; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
104459
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
890
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
56
|
|
9
|
1
|
|
|
1
|
|
421
|
use Catmandu; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
243
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
752
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
16
|
|
|
|
|
|
|
has name => (fix_arg => 1); |
17
|
|
|
|
|
|
|
has opts => (fix_opt => 'collect'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _build_fixer { |
20
|
6
|
|
|
6
|
|
58
|
my ($self) = @_; |
21
|
6
|
|
|
|
|
16
|
my $name = $self->name; |
22
|
6
|
|
|
|
|
50
|
my $opts = $self->opts; |
23
|
|
|
|
|
|
|
as_path($self->path)->updater( |
24
|
|
|
|
|
|
|
if => [ |
25
|
|
|
|
|
|
|
[qw(array_ref hash_ref)] => |
26
|
6
|
|
|
6
|
|
46
|
sub {Catmandu->export_to_string($_[0], $name, %$opts)} |
27
|
6
|
|
|
|
|
28
|
] |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Catmandu::Fix::export_to_string - convert the value of field using a named exporter |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
export_to_string(my.field,'YAML') |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
export_to_string(my.field2,'JSON') |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
export_to_string(my.field3,'CSV', 'sep_char' => ';' ) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 export_string( PATH, NAME [, EXPORT_OPTIONS ] ) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This fix uses the function export_to_string of the package L<Catmandu>, but requires the NAME of the exporter. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
It expects a HASH or ARRAY as input. Other values are silently ignored. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item PATH |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
name of the exporter to use. As usual in Catmandu, one can choose: |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
* full package name of the exporter (e.g. 'Catmandu::Exporter::JSON') |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
* short package name of the exporter (e.g. 'JSON') |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
* name of the exporter as declared in the Catmandu configuration |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item EXPORT_OPTIONS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
extra options for the named exporter |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Nicolas Franck, C<< <nicolas.franck at ugent.be> >> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<Catmandu::Fix> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|