line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package YAML; |
3
|
1
|
|
|
1
|
|
546
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use 5.008; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
1593
|
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.70'; |
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
|
|
|
|
|
|
|
local $/ = "\n"; # reset special to "sane" |
63
|
|
|
|
|
|
|
print $OUT Dump(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub LoadFile { |
67
|
|
|
|
|
|
|
my $IN; |
68
|
|
|
|
|
|
|
my $filename = shift; |
69
|
|
|
|
|
|
|
if (ref $filename eq 'GLOB') { |
70
|
|
|
|
|
|
|
$IN = $filename; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
|
|
|
|
|
|
open $IN, $filename |
74
|
|
|
|
|
|
|
or YAML::Base->die('YAML_LOAD_ERR_FILE_INPUT', $filename, $!); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
return Load(do { local $/; <$IN> }); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub init_action_object { |
80
|
|
|
|
|
|
|
my $self = shift; |
81
|
|
|
|
|
|
|
my $object_class = (shift) . '_class'; |
82
|
|
|
|
|
|
|
my $module_name = $self->$object_class; |
83
|
|
|
|
|
|
|
eval "require $module_name"; |
84
|
|
|
|
|
|
|
$self->die("Error in require $module_name - $@") |
85
|
|
|
|
|
|
|
if $@ and "$@" !~ /Can't locate/; |
86
|
|
|
|
|
|
|
my $object = $self->$object_class->new; |
87
|
|
|
|
|
|
|
$object->set_global_options; |
88
|
|
|
|
|
|
|
return $object; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $global = {}; |
92
|
|
|
|
|
|
|
sub Bless { |
93
|
|
|
|
|
|
|
require YAML::Dumper::Base; |
94
|
|
|
|
|
|
|
YAML::Dumper::Base::bless($global, @_) |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
sub Blessed { |
97
|
|
|
|
|
|
|
require YAML::Dumper::Base; |
98
|
|
|
|
|
|
|
YAML::Dumper::Base::blessed($global, @_) |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
sub global_object { $global } |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |