line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
4
|
|
|
4
|
|
91182
|
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
32
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use YAML::XS (); |
7
|
4
|
|
|
4
|
|
25
|
use Moo; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
72
|
|
8
|
4
|
|
|
4
|
|
18
|
use namespace::clean; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
24
|
|
9
|
4
|
|
|
4
|
|
1299
|
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
27
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Exporter'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my ($self, $data) = @_; |
13
|
|
|
|
|
|
|
my $yaml = YAML::XS::Dump($data); |
14
|
|
|
|
|
|
|
utf8::decode($yaml); |
15
|
|
|
|
|
|
|
$self->fh->print($yaml); |
16
|
|
|
|
|
|
|
$self->fh->print("...\n"); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Catmandu::Exporter::YAML - a YAML exporter |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# From the commandline |
31
|
|
|
|
|
|
|
$ catmandu convert JSON --fix myfixes to YAML < /tmp/data.json |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# From Perl |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Catmandu; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Print to STDOUT |
38
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('YAML', fix => 'myfix.txt'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Print to file or IO::Handle |
41
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('YAML', file => '/tmp/out.yml'); |
42
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('YAML', file => $fh); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$exporter->add_many($arrayref); |
45
|
|
|
|
|
|
|
$exporter->add_many($iterator); |
46
|
|
|
|
|
|
|
$exporter->add_many(sub { }); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$exporter->add($hashref); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
printf "exported %d items\n" , $exporter->count; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 CONFIGURATION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item file |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Write output to a local file given by its path or file handle. Alternatively a |
59
|
|
|
|
|
|
|
scalar reference can be passed to write to a string and a code reference can be |
60
|
|
|
|
|
|
|
used to write to a callback function. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item fh |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Write the output to an L<IO::Handle>. If not specified, |
65
|
|
|
|
|
|
|
L<Catmandu::Util::io|Catmandu::Util/IO-functions> is used to create the output |
66
|
|
|
|
|
|
|
handle from the C<file> argument or by using STDOUT. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item fix |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
An ARRAY of one or more fixes or file scripts to be applied to exported items. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item encoding |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Binmode of the output stream C<fh>. Set to "C<:utf8>" by default. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L<Catmandu::Exporter>, L<Catmandu::Importer::YAML> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |