line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#======================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Badger::Codec::YAML |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Codec module for encoding/decoding YAML |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# AUTHOR |
9
|
|
|
|
|
|
|
# Andy Wardley |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
#======================================================================== |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Badger::Codec::YAML; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Badger::Class |
16
|
3
|
|
|
|
|
40
|
version => 0.01, |
17
|
|
|
|
|
|
|
base => 'Badger::Codec', |
18
|
3
|
|
|
3
|
|
1558
|
import => 'class CLASS'; |
|
3
|
|
|
|
|
6
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
eval "require YAML::XS"; |
21
|
|
|
|
|
|
|
our $HAS_YAML_XS = $@ ? 0 : 1; |
22
|
|
|
|
|
|
|
our $HAS_YAML; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
unless ($HAS_YAML_XS) { |
25
|
|
|
|
|
|
|
eval "require YAML"; |
26
|
|
|
|
|
|
|
$HAS_YAML = $@ ? 0 : 1; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $MODULE = |
30
|
|
|
|
|
|
|
$HAS_YAML_XS ? 'YAML::XS' : |
31
|
|
|
|
|
|
|
$HAS_YAML ? 'YAML' : |
32
|
|
|
|
|
|
|
CLASS->error("You don't have YAML or YAML::XS installed"); |
33
|
|
|
|
|
|
|
#die "No YAML implementation installed\n"; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
*yaml_dump = $HAS_YAML_XS ? \&YAML::XS::Dump : \&YAML::Dump; |
36
|
|
|
|
|
|
|
*yaml_load = $HAS_YAML_XS ? \&YAML::XS::Load : \&YAML::Load; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub encode { |
39
|
0
|
|
|
0
|
|
|
my $self = shift; |
40
|
0
|
|
|
|
|
|
yaml_dump(shift); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub decode { |
44
|
0
|
|
|
0
|
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
yaml_load(shift); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# shortcuts straight to the real encoder/decoder subs for efficient aliasing |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub encoder { |
51
|
0
|
|
|
0
|
|
|
\&yaml_dump; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub decoder { |
55
|
0
|
|
|
0
|
|
|
\&yaml_load; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |