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