| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Sisimai::Data::YAML; |
|
2
|
2
|
|
|
2
|
|
1300
|
use feature ':5.10'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
151
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
31
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
447
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub dump { |
|
7
|
|
|
|
|
|
|
# Data dumper(YAML) |
|
8
|
|
|
|
|
|
|
# @param [Sisimai::Data] argvs Object |
|
9
|
|
|
|
|
|
|
# @return [String, Undef] Dumped data or Undef if the argument is |
|
10
|
|
|
|
|
|
|
# missing |
|
11
|
1
|
|
|
1
|
0
|
1407
|
my $class = shift; |
|
12
|
1
|
|
50
|
|
|
4
|
my $argvs = shift // return undef; |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
50
|
|
|
|
5
|
return undef unless ref $argvs eq 'Sisimai::Data'; |
|
15
|
0
|
|
|
|
|
|
my $damneddata = undef; |
|
16
|
0
|
|
|
|
|
|
my $yamlstring = undef; |
|
17
|
0
|
|
|
|
|
|
my $modulename = undef; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
eval { |
|
20
|
0
|
|
|
|
|
|
require YAML; |
|
21
|
0
|
|
|
|
|
|
$modulename = 'YAML'; |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
0
|
0
|
|
|
|
|
if( $@ ) { |
|
24
|
|
|
|
|
|
|
# Try to load YAML::Syck |
|
25
|
0
|
|
|
|
|
|
eval { |
|
26
|
0
|
|
|
|
|
|
require YAML::Syck; |
|
27
|
0
|
|
|
|
|
|
$modulename = 'YAML::Syck'; |
|
28
|
|
|
|
|
|
|
}; |
|
29
|
0
|
0
|
|
|
|
|
die ' ***error: Neither "YAML" nor "YAML::Syck" module is installed' if $@; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$damneddata = $argvs->damn; |
|
33
|
0
|
0
|
|
|
|
|
if( $modulename eq 'YAML' ) { |
|
|
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Use YAML module |
|
35
|
0
|
|
|
|
|
|
local $YAML::SortKeys = 1; |
|
36
|
0
|
|
|
|
|
|
local $YAML::Stringify = 0; |
|
37
|
0
|
|
|
|
|
|
local $YAML::UseHeader = 1; |
|
38
|
0
|
|
|
|
|
|
local $YAML::UseBlock = 0; |
|
39
|
0
|
|
|
|
|
|
local $YAML::CompressSeries = 0; |
|
40
|
0
|
|
|
|
|
|
$yamlstring = YAML::Dump($damneddata); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} elsif( $modulename eq 'YAML::Syck' ) { |
|
43
|
|
|
|
|
|
|
# Use YAML::Syck module instead of YAML module. |
|
44
|
0
|
|
|
|
|
|
local $YAML::Syck::ImplicitTyping = 1; |
|
45
|
0
|
|
|
|
|
|
local $YAML::Syck::Headless = 0; |
|
46
|
0
|
|
|
|
|
|
local $YAML::Syck::ImplicitUnicode = 1; |
|
47
|
0
|
|
|
|
|
|
local $YAML::Syck::SingleQuote = 0; |
|
48
|
0
|
|
|
|
|
|
local $YAML::Syck::SortKeys = 1; |
|
49
|
0
|
|
|
|
|
|
$yamlstring = YAML::Syck::Dump($damneddata); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return $yamlstring; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
__END__ |