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