line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Format::Pretty::YAML; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
676
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
347
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(format_pretty); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.07'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
0
|
sub content_type { "text/yaml" } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub format_pretty { |
16
|
1
|
|
|
1
|
1
|
1169
|
my ($data, $opts) = @_; |
17
|
1
|
|
50
|
|
|
6
|
$opts //= {}; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
9
|
my $interactive = (-t STDOUT); |
20
|
1
|
|
50
|
|
|
10
|
my $pretty = $opts->{pretty} // 1; |
21
|
1
|
|
33
|
|
|
15
|
my $color = $opts->{color} // $ENV{COLOR} // $interactive // |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
22
|
|
|
|
|
|
|
$opts->{pretty}; |
23
|
1
|
|
33
|
|
|
11
|
my $linum = $opts->{linum} // $ENV{LINUM} // 0; |
|
|
|
50
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
4
|
if ($color) { |
26
|
0
|
|
|
|
|
0
|
require YAML::Tiny::Color; |
27
|
0
|
|
|
|
|
0
|
local $YAML::Tiny::Color::LineNumber = $linum; |
28
|
0
|
|
|
|
|
0
|
YAML::Tiny::Color::Dump($data); |
29
|
|
|
|
|
|
|
} else { |
30
|
1
|
|
|
|
|
1045
|
require YAML::Syck; |
31
|
1
|
|
|
|
|
2368
|
local $YAML::Syck::ImplicitTyping = 1; |
32
|
1
|
|
|
|
|
3
|
local $YAML::Syck::SortKeys = 1; |
33
|
1
|
|
|
|
|
2
|
local $YAML::Syck::Headless = 1; |
34
|
1
|
50
|
|
|
|
5
|
if ($linum) { |
35
|
0
|
|
|
|
|
0
|
require SHARYANTO::String::Util; |
36
|
0
|
|
|
|
|
0
|
SHARYANTO::String::Util::linenum(YAML::Syck::Dump($data)); |
37
|
|
|
|
|
|
|
} else { |
38
|
1
|
|
|
|
|
7
|
YAML::Syck::Dump($data); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
# ABSTRACT: Pretty-print data structure as YAML |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |