line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package YAML; |
3
|
4
|
|
|
4
|
|
117
|
|
|
4
|
|
|
|
|
24
|
|
|
4
|
|
|
|
|
176
|
|
4
|
4
|
|
|
4
|
|
25
|
use 5.008001; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
144
|
|
5
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
135
|
|
6
|
4
|
|
|
4
|
|
1970
|
use warnings; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use YAML::Base; |
8
|
|
|
|
|
|
|
use YAML::Node; # XXX This is a temp fix for Module::Build |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.71'; |
11
|
|
|
|
|
|
|
our @ISA = 'YAML::Base'; |
12
|
|
|
|
|
|
|
our @EXPORT = qw{ Dump Load }; |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ freeze thaw DumpFile LoadFile Bless Blessed }; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# XXX This VALUE nonsense needs to go. |
16
|
|
|
|
|
|
|
use constant VALUE => "\x07YAML\x07VALUE\x07"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# YAML Object Properties |
19
|
|
|
|
|
|
|
field dumper_class => 'YAML::Dumper'; |
20
|
|
|
|
|
|
|
field loader_class => 'YAML::Loader'; |
21
|
|
|
|
|
|
|
field dumper_object => |
22
|
|
|
|
|
|
|
-init => '$self->init_action_object("dumper")'; |
23
|
|
|
|
|
|
|
field loader_object => |
24
|
|
|
|
|
|
|
-init => '$self->init_action_object("loader")'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub Dump { |
27
|
|
|
|
|
|
|
my $yaml = YAML->new; |
28
|
|
|
|
|
|
|
$yaml->dumper_class($YAML::DumperClass) |
29
|
|
|
|
|
|
|
if $YAML::DumperClass; |
30
|
|
|
|
|
|
|
return $yaml->dumper_object->dump(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Load { |
34
|
|
|
|
|
|
|
my $yaml = YAML->new; |
35
|
|
|
|
|
|
|
$yaml->loader_class($YAML::LoaderClass) |
36
|
|
|
|
|
|
|
if $YAML::LoaderClass; |
37
|
|
|
|
|
|
|
return $yaml->loader_object->load(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
no warnings 'once'; |
42
|
|
|
|
|
|
|
# freeze/thaw is the API for Storable string serialization. Some |
43
|
|
|
|
|
|
|
# modules make use of serializing packages on if they use freeze/thaw. |
44
|
|
|
|
|
|
|
*freeze = \ &Dump; |
45
|
|
|
|
|
|
|
*thaw = \ &Load; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub DumpFile { |
49
|
|
|
|
|
|
|
my $OUT; |
50
|
|
|
|
|
|
|
my $filename = shift; |
51
|
|
|
|
|
|
|
if (ref $filename eq 'GLOB') { |
52
|
|
|
|
|
|
|
$OUT = $filename; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
|
|
|
|
|
|
my $mode = '>'; |
56
|
|
|
|
|
|
|
if ($filename =~ /^\s*(>{1,2})\s*(.*)$/) { |
57
|
|
|
|
|
|
|
($mode, $filename) = ($1, $2); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
open $OUT, $mode, $filename |
60
|
|
|
|
|
|
|
or YAML::Base->die('YAML_DUMP_ERR_FILE_OUTPUT', $filename, $!); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
binmode $OUT, ':utf8'; # if $Config{useperlio} eq 'define'; |
63
|
|
|
|
|
|
|
local $/ = "\n"; # reset special to "sane" |
64
|
|
|
|
|
|
|
print $OUT Dump(@_); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub LoadFile { |
68
|
|
|
|
|
|
|
my $IN; |
69
|
|
|
|
|
|
|
my $filename = shift; |
70
|
|
|
|
|
|
|
if (ref $filename eq 'GLOB') { |
71
|
|
|
|
|
|
|
$IN = $filename; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
|
|
|
|
|
|
open $IN, '<', $filename |
75
|
|
|
|
|
|
|
or YAML::Base->die('YAML_LOAD_ERR_FILE_INPUT', $filename, $!); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
binmode $IN, ':utf8'; # if $Config{useperlio} eq 'define'; |
78
|
|
|
|
|
|
|
return Load(do { local $/; <$IN> }); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub init_action_object { |
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
my $object_class = (shift) . '_class'; |
84
|
|
|
|
|
|
|
my $module_name = $self->$object_class; |
85
|
|
|
|
|
|
|
eval "require $module_name"; |
86
|
|
|
|
|
|
|
$self->die("Error in require $module_name - $@") |
87
|
|
|
|
|
|
|
if $@ and "$@" !~ /Can't locate/; |
88
|
|
|
|
|
|
|
my $object = $self->$object_class->new; |
89
|
|
|
|
|
|
|
$object->set_global_options; |
90
|
|
|
|
|
|
|
return $object; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $global = {}; |
94
|
|
|
|
|
|
|
sub Bless { |
95
|
|
|
|
|
|
|
require YAML::Dumper::Base; |
96
|
|
|
|
|
|
|
YAML::Dumper::Base::bless($global, @_) |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
sub Blessed { |
99
|
|
|
|
|
|
|
require YAML::Dumper::Base; |
100
|
|
|
|
|
|
|
YAML::Dumper::Base::blessed($global, @_) |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
sub global_object { $global } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |