line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hades::Macro::YAML; |
2
|
2
|
|
|
2
|
|
138402
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
61
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
11
|
use base qw/Hades::Macro/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1084
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.01; |
6
|
|
|
|
|
|
|
our ( $YAML_CLASS, $CLASS_LOADED ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
|
|
|
|
|
|
$YAML_CLASS = eval { |
10
|
|
|
|
|
|
|
require YAML::XS; |
11
|
|
|
|
|
|
|
'YAML::XS'; |
12
|
|
|
|
|
|
|
} || eval { |
13
|
|
|
|
|
|
|
require YAML::PP; |
14
|
|
|
|
|
|
|
'YAML::PP'; |
15
|
2
|
|
33
|
2
|
|
1672
|
} || eval { |
16
|
|
|
|
|
|
|
require YAML; |
17
|
|
|
|
|
|
|
'YAML'; |
18
|
|
|
|
|
|
|
}; |
19
|
2
|
50
|
|
|
|
10490
|
die |
20
|
|
|
|
|
|
|
'No supported YAML module installed - supported modules are YAML::XS, YAML::PP or YAML' |
21
|
|
|
|
|
|
|
unless $YAML_CLASS; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
24
|
100
|
|
24
|
1
|
55913
|
my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); |
|
22
|
|
|
|
|
70
|
|
26
|
24
|
|
|
|
|
95
|
my $self = $cls->SUPER::new(%args); |
27
|
22
|
|
|
|
|
290
|
my %accessors = ( |
28
|
|
|
|
|
|
|
macro => { |
29
|
|
|
|
|
|
|
default => [ |
30
|
|
|
|
|
|
|
qw/ |
31
|
|
|
|
|
|
|
yaml_load_string |
32
|
|
|
|
|
|
|
yaml_load_file |
33
|
|
|
|
|
|
|
yaml_write_string |
34
|
|
|
|
|
|
|
yaml_write_file |
35
|
|
|
|
|
|
|
/ |
36
|
|
|
|
|
|
|
], |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
22
|
|
|
|
|
57
|
for my $accessor ( keys %accessors ) { |
40
|
|
|
|
|
|
|
my $param |
41
|
|
|
|
|
|
|
= defined $args{$accessor} |
42
|
|
|
|
|
|
|
? $args{$accessor} |
43
|
22
|
100
|
|
|
|
53
|
: $accessors{$accessor}->{default}; |
44
|
|
|
|
|
|
|
my $value |
45
|
|
|
|
|
|
|
= $self->$accessor( $accessors{$accessor}->{builder} |
46
|
22
|
50
|
|
|
|
61
|
? $accessors{$accessor}->{builder}->( $self, $param ) |
47
|
|
|
|
|
|
|
: $param ); |
48
|
22
|
50
|
33
|
|
|
65
|
unless ( !$accessors{$accessor}->{required} || defined $value ) { |
49
|
0
|
|
|
|
|
0
|
die "$accessor accessor is required"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
22
|
|
|
|
|
133
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub macro { |
56
|
51
|
|
|
51
|
1
|
2012
|
my ( $self, $value ) = @_; |
57
|
51
|
100
|
|
|
|
110
|
if ( defined $value ) { |
58
|
49
|
100
|
100
|
|
|
142
|
if ( ( ref($value) || "" ) ne "ARRAY" ) { |
59
|
4
|
|
|
|
|
39
|
die qq{ArrayRef: invalid value $value for accessor macro}; |
60
|
|
|
|
|
|
|
} |
61
|
45
|
|
|
|
|
83
|
$self->{macro} = $value; |
62
|
|
|
|
|
|
|
} |
63
|
47
|
|
|
|
|
110
|
return $self->{macro}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub yaml_load_string { |
67
|
8
|
|
|
8
|
1
|
4997
|
my ( $self, $mg, $str, $param, $list ) = @_; |
68
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
69
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
70
|
2
|
|
|
|
|
18
|
die |
71
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method yaml_load_string}; |
72
|
|
|
|
|
|
|
} |
73
|
6
|
100
|
66
|
|
|
32
|
if ( !defined($str) || ref $str ) { |
74
|
2
|
50
|
|
|
|
6
|
$str = defined $str ? $str : 'undef'; |
75
|
2
|
|
|
|
|
21
|
die |
76
|
|
|
|
|
|
|
qq{Str: invalid value $str for variable \$str in method yaml_load_string}; |
77
|
|
|
|
|
|
|
} |
78
|
4
|
100
|
|
|
|
10
|
if ( defined $param ) { |
79
|
2
|
50
|
|
|
|
4
|
if ( ref $param ) { |
80
|
2
|
|
|
|
|
19
|
die |
81
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method yaml_load_string}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
85
|
2
|
|
|
|
|
6
|
my $ref = ref $list; |
86
|
2
|
0
|
50
|
|
|
9
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
87
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
88
|
|
|
|
|
|
|
{ |
89
|
2
|
|
|
|
|
20
|
die |
90
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method yaml_load_string}; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
0
|
unless ($CLASS_LOADED) { |
96
|
0
|
|
|
|
|
0
|
$mg->use($YAML_CLASS); |
97
|
|
|
|
|
|
|
} |
98
|
0
|
|
|
|
|
0
|
( my $uf = $YAML_CLASS ) =~ s/\:\:/_/g; |
99
|
0
|
|
|
|
|
0
|
my $cb = "_yaml_load_string_$uf"; |
100
|
0
|
|
|
|
|
0
|
return __PACKAGE__->$cb( $mg, $str, $param, $list ); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _yaml_load_string_YAML { |
105
|
8
|
|
|
8
|
|
4990
|
my ( $self, $mg, $str, $param, $list ) = @_; |
106
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
107
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
108
|
2
|
|
|
|
|
18
|
die |
109
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_string_YAML}; |
110
|
|
|
|
|
|
|
} |
111
|
6
|
100
|
66
|
|
|
33
|
if ( !defined($str) || ref $str ) { |
112
|
2
|
50
|
|
|
|
6
|
$str = defined $str ? $str : 'undef'; |
113
|
2
|
|
|
|
|
20
|
die |
114
|
|
|
|
|
|
|
qq{Str: invalid value $str for variable \$str in method _yaml_load_string_YAML}; |
115
|
|
|
|
|
|
|
} |
116
|
4
|
100
|
|
|
|
13
|
if ( defined $param ) { |
117
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
118
|
2
|
|
|
|
|
19
|
die |
119
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_string_YAML}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
2
|
50
|
|
|
|
6
|
if ( defined $list ) { |
123
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
124
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
125
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
126
|
|
|
|
|
|
|
{ |
127
|
2
|
|
|
|
|
20
|
die |
128
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_string_YAML}; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
my $code = q||; |
134
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
135
|
0
|
|
|
|
|
0
|
$code .= qq|YAML::Load($str)|; |
136
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
137
|
0
|
|
|
|
|
0
|
return $code; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub _yaml_load_string_YAML_XS { |
142
|
8
|
|
|
8
|
|
5014
|
my ( $self, $mg, $str, $param, $list ) = @_; |
143
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
144
|
2
|
50
|
|
|
|
9
|
$mg = defined $mg ? $mg : 'undef'; |
145
|
2
|
|
|
|
|
20
|
die |
146
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_string_YAML_XS}; |
147
|
|
|
|
|
|
|
} |
148
|
6
|
100
|
66
|
|
|
36
|
if ( !defined($str) || ref $str ) { |
149
|
2
|
50
|
|
|
|
6
|
$str = defined $str ? $str : 'undef'; |
150
|
2
|
|
|
|
|
20
|
die |
151
|
|
|
|
|
|
|
qq{Str: invalid value $str for variable \$str in method _yaml_load_string_YAML_XS}; |
152
|
|
|
|
|
|
|
} |
153
|
4
|
100
|
|
|
|
12
|
if ( defined $param ) { |
154
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
155
|
2
|
|
|
|
|
22
|
die |
156
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_string_YAML_XS}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} |
159
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
160
|
2
|
|
|
|
|
4
|
my $ref = ref $list; |
161
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
162
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
163
|
|
|
|
|
|
|
{ |
164
|
2
|
|
|
|
|
21
|
die |
165
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_string_YAML_XS}; |
166
|
|
|
|
|
|
|
} |
167
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
0
|
my $code = q||; |
171
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
172
|
0
|
|
|
|
|
0
|
$code .= qq|Load($str)|; |
173
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
174
|
0
|
|
|
|
|
0
|
return $code; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub _yaml_load_string_YAML_PP { |
179
|
8
|
|
|
8
|
|
5135
|
my ( $self, $mg, $str, $param, $list ) = @_; |
180
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
181
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
182
|
2
|
|
|
|
|
18
|
die |
183
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_string_YAML_PP}; |
184
|
|
|
|
|
|
|
} |
185
|
6
|
100
|
66
|
|
|
32
|
if ( !defined($str) || ref $str ) { |
186
|
2
|
50
|
|
|
|
6
|
$str = defined $str ? $str : 'undef'; |
187
|
2
|
|
|
|
|
21
|
die |
188
|
|
|
|
|
|
|
qq{Str: invalid value $str for variable \$str in method _yaml_load_string_YAML_PP}; |
189
|
|
|
|
|
|
|
} |
190
|
4
|
100
|
|
|
|
13
|
if ( defined $param ) { |
191
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
192
|
2
|
|
|
|
|
19
|
die |
193
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_string_YAML_PP}; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
2
|
50
|
|
|
|
6
|
if ( defined $list ) { |
197
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
198
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
199
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
200
|
|
|
|
|
|
|
{ |
201
|
2
|
|
|
|
|
20
|
die |
202
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_string_YAML_PP}; |
203
|
|
|
|
|
|
|
} |
204
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
0
|
my $code = q|my $lpp = YAML::PP->new;|; |
208
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
209
|
0
|
|
|
|
|
0
|
$code .= qq|\$lpp->load_string($str);|; |
210
|
0
|
0
|
|
|
|
0
|
$code = $list ? qq|do { $code },| : qq|$code;|; |
211
|
0
|
|
|
|
|
0
|
return $code; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub yaml_load_file { |
216
|
8
|
|
|
8
|
1
|
5112
|
my ( $self, $mg, $file, $param, $list ) = @_; |
217
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
218
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
219
|
2
|
|
|
|
|
20
|
die |
220
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method yaml_load_file}; |
221
|
|
|
|
|
|
|
} |
222
|
6
|
100
|
66
|
|
|
30
|
if ( !defined($file) || ref $file ) { |
223
|
2
|
50
|
|
|
|
7
|
$file = defined $file ? $file : 'undef'; |
224
|
2
|
|
|
|
|
21
|
die |
225
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method yaml_load_file}; |
226
|
|
|
|
|
|
|
} |
227
|
4
|
100
|
|
|
|
13
|
if ( defined $param ) { |
228
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
229
|
2
|
|
|
|
|
20
|
die |
230
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method yaml_load_file}; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
} |
233
|
2
|
50
|
|
|
|
10
|
if ( defined $list ) { |
234
|
2
|
|
|
|
|
7
|
my $ref = ref $list; |
235
|
2
|
0
|
50
|
|
|
11
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
236
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
237
|
|
|
|
|
|
|
{ |
238
|
2
|
|
|
|
|
19
|
die |
239
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method yaml_load_file}; |
240
|
|
|
|
|
|
|
} |
241
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
0
|
0
|
|
|
|
0
|
unless ($CLASS_LOADED) { |
245
|
0
|
|
|
|
|
0
|
$mg->use($YAML_CLASS); |
246
|
|
|
|
|
|
|
} |
247
|
0
|
|
|
|
|
0
|
( my $uf = $YAML_CLASS ) =~ s/\:\:/_/g; |
248
|
0
|
|
|
|
|
0
|
my $cb = "_yaml_load_file_$uf"; |
249
|
0
|
|
|
|
|
0
|
return __PACKAGE__->$cb( $mg, $file, $param, $list ); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub _yaml_load_file_YAML { |
254
|
8
|
|
|
8
|
|
4938
|
my ( $self, $mg, $file, $param, $list ) = @_; |
255
|
8
|
100
|
100
|
|
|
61
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
256
|
2
|
50
|
|
|
|
6
|
$mg = defined $mg ? $mg : 'undef'; |
257
|
2
|
|
|
|
|
20
|
die |
258
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_file_YAML}; |
259
|
|
|
|
|
|
|
} |
260
|
6
|
100
|
66
|
|
|
32
|
if ( !defined($file) || ref $file ) { |
261
|
2
|
50
|
|
|
|
11
|
$file = defined $file ? $file : 'undef'; |
262
|
2
|
|
|
|
|
19
|
die |
263
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_load_file_YAML}; |
264
|
|
|
|
|
|
|
} |
265
|
4
|
100
|
|
|
|
10
|
if ( defined $param ) { |
266
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
267
|
2
|
|
|
|
|
21
|
die |
268
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_file_YAML}; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
272
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
273
|
2
|
0
|
50
|
|
|
12
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
274
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
275
|
|
|
|
|
|
|
{ |
276
|
2
|
|
|
|
|
20
|
die |
277
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_file_YAML}; |
278
|
|
|
|
|
|
|
} |
279
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
0
|
my $code = q||; |
283
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
284
|
0
|
|
|
|
|
0
|
$code .= qq|YAML::LoadFile($file)|; |
285
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
286
|
0
|
|
|
|
|
0
|
return $code; |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub _yaml_load_file_YAML_XS { |
291
|
8
|
|
|
8
|
|
4918
|
my ( $self, $mg, $file, $param, $list ) = @_; |
292
|
8
|
100
|
100
|
|
|
60
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
293
|
2
|
50
|
|
|
|
9
|
$mg = defined $mg ? $mg : 'undef'; |
294
|
2
|
|
|
|
|
20
|
die |
295
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_file_YAML_XS}; |
296
|
|
|
|
|
|
|
} |
297
|
6
|
100
|
66
|
|
|
34
|
if ( !defined($file) || ref $file ) { |
298
|
2
|
50
|
|
|
|
6
|
$file = defined $file ? $file : 'undef'; |
299
|
2
|
|
|
|
|
20
|
die |
300
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_load_file_YAML_XS}; |
301
|
|
|
|
|
|
|
} |
302
|
4
|
100
|
|
|
|
11
|
if ( defined $param ) { |
303
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
304
|
2
|
|
|
|
|
20
|
die |
305
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_file_YAML_XS}; |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
} |
308
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
309
|
2
|
|
|
|
|
4
|
my $ref = ref $list; |
310
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
311
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
312
|
|
|
|
|
|
|
{ |
313
|
2
|
|
|
|
|
21
|
die |
314
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_file_YAML_XS}; |
315
|
|
|
|
|
|
|
} |
316
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
0
|
my $code = q||; |
320
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
321
|
0
|
|
|
|
|
0
|
$code .= qq|LoadFile($file)|; |
322
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
323
|
0
|
|
|
|
|
0
|
return $code; |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub _yaml_load_file_YAML_PP { |
328
|
8
|
|
|
8
|
|
4928
|
my ( $self, $mg, $file, $param, $list ) = @_; |
329
|
8
|
100
|
100
|
|
|
61
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
330
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
331
|
2
|
|
|
|
|
20
|
die |
332
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_load_file_YAML_PP}; |
333
|
|
|
|
|
|
|
} |
334
|
6
|
100
|
66
|
|
|
63
|
if ( !defined($file) || ref $file ) { |
335
|
2
|
50
|
|
|
|
7
|
$file = defined $file ? $file : 'undef'; |
336
|
2
|
|
|
|
|
19
|
die |
337
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_load_file_YAML_PP}; |
338
|
|
|
|
|
|
|
} |
339
|
4
|
100
|
|
|
|
10
|
if ( defined $param ) { |
340
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
341
|
2
|
|
|
|
|
19
|
die |
342
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_load_file_YAML_PP}; |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
2
|
50
|
|
|
|
8
|
if ( defined $list ) { |
346
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
347
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
348
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
349
|
|
|
|
|
|
|
{ |
350
|
2
|
|
|
|
|
21
|
die |
351
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_load_file_YAML_PP}; |
352
|
|
|
|
|
|
|
} |
353
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
0
|
|
|
|
|
0
|
my $code = q|my $lpp = YAML::PP->new;|; |
357
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
358
|
0
|
|
|
|
|
0
|
$code .= qq|\$lpp->load_file($file);|; |
359
|
0
|
0
|
|
|
|
0
|
$code = $list ? qq|do { $code },| : qq|$code;|; |
360
|
0
|
|
|
|
|
0
|
return $code; |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
sub yaml_write_string { |
365
|
8
|
|
|
8
|
1
|
4660
|
my ( $self, $mg, $content, $param, $list ) = @_; |
366
|
8
|
100
|
100
|
|
|
73
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
367
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
368
|
2
|
|
|
|
|
30
|
die |
369
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method yaml_write_string}; |
370
|
|
|
|
|
|
|
} |
371
|
6
|
100
|
66
|
|
|
33
|
if ( !defined($content) || ref $content ) { |
372
|
2
|
50
|
|
|
|
6
|
$content = defined $content ? $content : 'undef'; |
373
|
2
|
|
|
|
|
20
|
die |
374
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method yaml_write_string}; |
375
|
|
|
|
|
|
|
} |
376
|
4
|
100
|
|
|
|
10
|
if ( defined $param ) { |
377
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
378
|
2
|
|
|
|
|
21
|
die |
379
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method yaml_write_string}; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
} |
382
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
383
|
2
|
|
|
|
|
6
|
my $ref = ref $list; |
384
|
2
|
0
|
50
|
|
|
12
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
385
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
386
|
|
|
|
|
|
|
{ |
387
|
2
|
|
|
|
|
19
|
die |
388
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method yaml_write_string}; |
389
|
|
|
|
|
|
|
} |
390
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
|
393
|
0
|
0
|
|
|
|
0
|
unless ($CLASS_LOADED) { |
394
|
0
|
|
|
|
|
0
|
$mg->use($YAML_CLASS); |
395
|
|
|
|
|
|
|
} |
396
|
0
|
|
|
|
|
0
|
( my $uf = $YAML_CLASS ) =~ s/\:\:/_/g; |
397
|
0
|
|
|
|
|
0
|
my $cb = "_yaml_write_string_$uf"; |
398
|
0
|
|
|
|
|
0
|
return __PACKAGE__->$cb( $mg, $content, $param, $list ); |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub _yaml_write_string_YAML { |
403
|
8
|
|
|
8
|
|
4804
|
my ( $self, $mg, $content, $param, $list ) = @_; |
404
|
8
|
100
|
100
|
|
|
59
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
405
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
406
|
2
|
|
|
|
|
19
|
die |
407
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_string_YAML}; |
408
|
|
|
|
|
|
|
} |
409
|
6
|
100
|
66
|
|
|
28
|
if ( !defined($content) || ref $content ) { |
410
|
2
|
50
|
|
|
|
8
|
$content = defined $content ? $content : 'undef'; |
411
|
2
|
|
|
|
|
19
|
die |
412
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_string_YAML}; |
413
|
|
|
|
|
|
|
} |
414
|
4
|
100
|
|
|
|
15
|
if ( defined $param ) { |
415
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
416
|
2
|
|
|
|
|
21
|
die |
417
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_string_YAML}; |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
} |
420
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
421
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
422
|
2
|
0
|
50
|
|
|
9
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
423
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
424
|
|
|
|
|
|
|
{ |
425
|
2
|
|
|
|
|
19
|
die |
426
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_string_YAML}; |
427
|
|
|
|
|
|
|
} |
428
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
0
|
|
|
|
|
0
|
my $code = q||; |
432
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
433
|
0
|
|
|
|
|
0
|
$code .= qq|YAML::Dump($content)|; |
434
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
435
|
0
|
|
|
|
|
0
|
return $code; |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
sub _yaml_write_string_YAML_XS { |
440
|
8
|
|
|
8
|
|
4371
|
my ( $self, $mg, $content, $param, $list ) = @_; |
441
|
8
|
100
|
100
|
|
|
57
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
442
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
443
|
2
|
|
|
|
|
19
|
die |
444
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_string_YAML_XS}; |
445
|
|
|
|
|
|
|
} |
446
|
6
|
100
|
66
|
|
|
59
|
if ( !defined($content) || ref $content ) { |
447
|
2
|
50
|
|
|
|
9
|
$content = defined $content ? $content : 'undef'; |
448
|
2
|
|
|
|
|
23
|
die |
449
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_string_YAML_XS}; |
450
|
|
|
|
|
|
|
} |
451
|
4
|
100
|
|
|
|
12
|
if ( defined $param ) { |
452
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
453
|
2
|
|
|
|
|
20
|
die |
454
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_string_YAML_XS}; |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
} |
457
|
2
|
50
|
|
|
|
6
|
if ( defined $list ) { |
458
|
2
|
|
|
|
|
6
|
my $ref = ref $list; |
459
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
460
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
461
|
|
|
|
|
|
|
{ |
462
|
2
|
|
|
|
|
20
|
die |
463
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_string_YAML_XS}; |
464
|
|
|
|
|
|
|
} |
465
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
0
|
|
|
|
|
0
|
my $code = q||; |
469
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
470
|
0
|
|
|
|
|
0
|
$code .= qq|Dump($content)|; |
471
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
472
|
0
|
|
|
|
|
0
|
return $code; |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
sub _yaml_write_string_YAML_PP { |
477
|
8
|
|
|
8
|
|
4443
|
my ( $self, $mg, $content, $param, $list ) = @_; |
478
|
8
|
100
|
100
|
|
|
72
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
479
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
480
|
2
|
|
|
|
|
21
|
die |
481
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_string_YAML_PP}; |
482
|
|
|
|
|
|
|
} |
483
|
6
|
100
|
66
|
|
|
31
|
if ( !defined($content) || ref $content ) { |
484
|
2
|
50
|
|
|
|
6
|
$content = defined $content ? $content : 'undef'; |
485
|
2
|
|
|
|
|
23
|
die |
486
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_string_YAML_PP}; |
487
|
|
|
|
|
|
|
} |
488
|
4
|
100
|
|
|
|
11
|
if ( defined $param ) { |
489
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
490
|
2
|
|
|
|
|
19
|
die |
491
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_string_YAML_PP}; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
} |
494
|
2
|
50
|
|
|
|
6
|
if ( defined $list ) { |
495
|
2
|
|
|
|
|
7
|
my $ref = ref $list; |
496
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
497
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
498
|
|
|
|
|
|
|
{ |
499
|
2
|
|
|
|
|
19
|
die |
500
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_string_YAML_PP}; |
501
|
|
|
|
|
|
|
} |
502
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
0
|
|
|
|
|
0
|
my $code = q|my $wpp = YAML::PP->new;|; |
506
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
507
|
0
|
|
|
|
|
0
|
$code .= qq|\$wpp->dump_string($content)|; |
508
|
0
|
0
|
|
|
|
0
|
$code = $list ? qq|do { $code },| : qq|$code;|; |
509
|
0
|
|
|
|
|
0
|
return $code; |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
sub yaml_write_file { |
514
|
10
|
|
|
10
|
1
|
5652
|
my ( $self, $mg, $file, $content, $param, $list ) = @_; |
515
|
10
|
100
|
100
|
|
|
72
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
516
|
2
|
50
|
|
|
|
7
|
$mg = defined $mg ? $mg : 'undef'; |
517
|
2
|
|
|
|
|
20
|
die |
518
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method yaml_write_file}; |
519
|
|
|
|
|
|
|
} |
520
|
8
|
100
|
66
|
|
|
38
|
if ( !defined($file) || ref $file ) { |
521
|
2
|
50
|
|
|
|
7
|
$file = defined $file ? $file : 'undef'; |
522
|
2
|
|
|
|
|
20
|
die |
523
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method yaml_write_file}; |
524
|
|
|
|
|
|
|
} |
525
|
6
|
100
|
66
|
|
|
23
|
if ( !defined($content) || ref $content ) { |
526
|
2
|
50
|
|
|
|
6
|
$content = defined $content ? $content : 'undef'; |
527
|
2
|
|
|
|
|
20
|
die |
528
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method yaml_write_file}; |
529
|
|
|
|
|
|
|
} |
530
|
4
|
100
|
|
|
|
41
|
if ( defined $param ) { |
531
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
532
|
2
|
|
|
|
|
19
|
die |
533
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method yaml_write_file}; |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
} |
536
|
2
|
50
|
|
|
|
9
|
if ( defined $list ) { |
537
|
2
|
|
|
|
|
6
|
my $ref = ref $list; |
538
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
539
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
540
|
|
|
|
|
|
|
{ |
541
|
2
|
|
|
|
|
21
|
die |
542
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method yaml_write_file}; |
543
|
|
|
|
|
|
|
} |
544
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
|
547
|
0
|
0
|
|
|
|
0
|
unless ($CLASS_LOADED) { |
548
|
0
|
|
|
|
|
0
|
$mg->use($YAML_CLASS); |
549
|
|
|
|
|
|
|
} |
550
|
0
|
|
|
|
|
0
|
( my $uf = $YAML_CLASS ) =~ s/\:\:/_/g; |
551
|
0
|
|
|
|
|
0
|
my $cb = "_yaml_write_file_$uf"; |
552
|
0
|
|
|
|
|
0
|
return __PACKAGE__->$cb( $mg, $file, $content, $param, $list ); |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
sub _yaml_write_file_YAML { |
557
|
10
|
|
|
10
|
|
5646
|
my ( $self, $mg, $file, $content, $param, $list ) = @_; |
558
|
10
|
100
|
100
|
|
|
69
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
559
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
560
|
2
|
|
|
|
|
19
|
die |
561
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_file_YAML}; |
562
|
|
|
|
|
|
|
} |
563
|
8
|
100
|
66
|
|
|
36
|
if ( !defined($file) || ref $file ) { |
564
|
2
|
50
|
|
|
|
10
|
$file = defined $file ? $file : 'undef'; |
565
|
2
|
|
|
|
|
41
|
die |
566
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_write_file_YAML}; |
567
|
|
|
|
|
|
|
} |
568
|
6
|
100
|
66
|
|
|
38
|
if ( !defined($content) || ref $content ) { |
569
|
2
|
50
|
|
|
|
7
|
$content = defined $content ? $content : 'undef'; |
570
|
2
|
|
|
|
|
19
|
die |
571
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_file_YAML}; |
572
|
|
|
|
|
|
|
} |
573
|
4
|
100
|
|
|
|
12
|
if ( defined $param ) { |
574
|
2
|
50
|
|
|
|
7
|
if ( ref $param ) { |
575
|
2
|
|
|
|
|
21
|
die |
576
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_file_YAML}; |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
} |
579
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
580
|
2
|
|
|
|
|
6
|
my $ref = ref $list; |
581
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
582
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
583
|
|
|
|
|
|
|
{ |
584
|
2
|
|
|
|
|
19
|
die |
585
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_file_YAML}; |
586
|
|
|
|
|
|
|
} |
587
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
|
590
|
0
|
|
|
|
|
0
|
my $code = q||; |
591
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
592
|
0
|
|
|
|
|
0
|
$code .= qq|YAML::DumpFile($file, $content)|; |
593
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
594
|
0
|
|
|
|
|
0
|
return $code; |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
sub _yaml_write_file_YAML_XS { |
599
|
10
|
|
|
10
|
|
5571
|
my ( $self, $mg, $file, $content, $param, $list ) = @_; |
600
|
10
|
100
|
100
|
|
|
70
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
601
|
2
|
50
|
|
|
|
6
|
$mg = defined $mg ? $mg : 'undef'; |
602
|
2
|
|
|
|
|
19
|
die |
603
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_file_YAML_XS}; |
604
|
|
|
|
|
|
|
} |
605
|
8
|
100
|
66
|
|
|
40
|
if ( !defined($file) || ref $file ) { |
606
|
2
|
50
|
|
|
|
6
|
$file = defined $file ? $file : 'undef'; |
607
|
2
|
|
|
|
|
20
|
die |
608
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_write_file_YAML_XS}; |
609
|
|
|
|
|
|
|
} |
610
|
6
|
100
|
66
|
|
|
52
|
if ( !defined($content) || ref $content ) { |
611
|
2
|
50
|
|
|
|
7
|
$content = defined $content ? $content : 'undef'; |
612
|
2
|
|
|
|
|
22
|
die |
613
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_file_YAML_XS}; |
614
|
|
|
|
|
|
|
} |
615
|
4
|
100
|
|
|
|
12
|
if ( defined $param ) { |
616
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
617
|
2
|
|
|
|
|
20
|
die |
618
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_file_YAML_XS}; |
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
} |
621
|
2
|
50
|
|
|
|
7
|
if ( defined $list ) { |
622
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
623
|
2
|
0
|
50
|
|
|
11
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
624
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
625
|
|
|
|
|
|
|
{ |
626
|
2
|
|
|
|
|
21
|
die |
627
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_file_YAML_XS}; |
628
|
|
|
|
|
|
|
} |
629
|
0
|
0
|
|
|
|
0
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
630
|
|
|
|
|
|
|
} |
631
|
|
|
|
|
|
|
|
632
|
0
|
|
|
|
|
0
|
my $code = q||; |
633
|
0
|
0
|
|
|
|
0
|
$code .= qq|$param = | if $param; |
634
|
0
|
|
|
|
|
0
|
$code .= qq|DumpFile($file, $content)|; |
635
|
0
|
0
|
|
|
|
0
|
$code .= $list ? q|,| : q|;|; |
636
|
0
|
|
|
|
|
0
|
return $code; |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
sub _yaml_write_file_YAML_PP { |
641
|
10
|
|
|
10
|
|
5609
|
my ( $self, $mg, $file, $content, $param, $list ) = @_; |
642
|
10
|
100
|
100
|
|
|
69
|
if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { |
643
|
2
|
50
|
|
|
|
8
|
$mg = defined $mg ? $mg : 'undef'; |
644
|
2
|
|
|
|
|
21
|
die |
645
|
|
|
|
|
|
|
qq{Object: invalid value $mg for variable \$mg in method _yaml_write_file_YAML_PP}; |
646
|
|
|
|
|
|
|
} |
647
|
8
|
100
|
66
|
|
|
40
|
if ( !defined($file) || ref $file ) { |
648
|
2
|
50
|
|
|
|
9
|
$file = defined $file ? $file : 'undef'; |
649
|
2
|
|
|
|
|
18
|
die |
650
|
|
|
|
|
|
|
qq{Str: invalid value $file for variable \$file in method _yaml_write_file_YAML_PP}; |
651
|
|
|
|
|
|
|
} |
652
|
6
|
100
|
66
|
|
|
26
|
if ( !defined($content) || ref $content ) { |
653
|
2
|
50
|
|
|
|
7
|
$content = defined $content ? $content : 'undef'; |
654
|
2
|
|
|
|
|
20
|
die |
655
|
|
|
|
|
|
|
qq{Str: invalid value $content for variable \$content in method _yaml_write_file_YAML_PP}; |
656
|
|
|
|
|
|
|
} |
657
|
4
|
100
|
|
|
|
15
|
if ( defined $param ) { |
658
|
2
|
50
|
|
|
|
6
|
if ( ref $param ) { |
659
|
2
|
|
|
|
|
19
|
die |
660
|
|
|
|
|
|
|
qq{Optional[Str]: invalid value $param for variable \$param in method _yaml_write_file_YAML_PP}; |
661
|
|
|
|
|
|
|
} |
662
|
|
|
|
|
|
|
} |
663
|
2
|
50
|
|
|
|
6
|
if ( defined $list ) { |
664
|
2
|
|
|
|
|
5
|
my $ref = ref $list; |
665
|
2
|
0
|
50
|
|
|
10
|
if ( ( $ref || 'SCALAR' ) ne 'SCALAR' |
|
|
50
|
33
|
|
|
|
|
666
|
|
|
|
|
|
|
|| ( $ref ? $$list : $list ) !~ m/^(1|0)$/ ) |
667
|
|
|
|
|
|
|
{ |
668
|
2
|
|
|
|
|
19
|
die |
669
|
|
|
|
|
|
|
qq{Optional[Bool]: invalid value $list for variable \$list in method _yaml_write_file_YAML_PP}; |
670
|
|
|
|
|
|
|
} |
671
|
0
|
0
|
|
|
|
|
$list = !!( $ref ? $$list : $list ) ? 1 : 0; |
|
|
0
|
|
|
|
|
|
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
0
|
|
|
|
|
|
my $code = q|my \$wpp = YAML::PP->new;|; |
675
|
0
|
0
|
|
|
|
|
$code .= qq|$param = | if $param; |
676
|
0
|
|
|
|
|
|
$code .= qq|\$wpp->load_file($file, $content);|; |
677
|
0
|
0
|
|
|
|
|
$code = $list ? qq|do { $code },| : qq|$code;|; |
678
|
0
|
|
|
|
|
|
return $code; |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
} |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
1; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
__END__ |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=head1 NAME |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
Hades::Macro::YAML - Hades macro helpers for YAML |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=head1 VERSION |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
Version 0.01 |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=cut |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
=head1 SYNOPSIS |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
Quick summary of what the module does: |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
Hades->run({ |
701
|
|
|
|
|
|
|
eval => q| |
702
|
|
|
|
|
|
|
macro { |
703
|
|
|
|
|
|
|
YAML |
704
|
|
|
|
|
|
|
} |
705
|
|
|
|
|
|
|
Kosmos { |
706
|
|
|
|
|
|
|
geras $file :t(Str) :d('path/to/file.yml') { |
707
|
|
|
|
|
|
|
€yaml_load_file($file); |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
} |
710
|
|
|
|
|
|
|
|; |
711
|
|
|
|
|
|
|
}); |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
... generates ... |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=head2 new |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
Instantiate a new Hades::Macro::YAML object. |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
Hades::Macro::YAML->new |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head2 yaml_load_string |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
call yaml_load_string method. Expects param $mg to be a Object, param $str to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
$obj->yaml_load_string($mg, $str, $param, $list) |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
=head2 _yaml_load_string_YAML |
730
|
|
|
|
|
|
|
|
731
|
|
|
|
|
|
|
call _yaml_load_string_YAML method. Expects param $mg to be a Object, param $str to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
732
|
|
|
|
|
|
|
|
733
|
|
|
|
|
|
|
$obj->_yaml_load_string_YAML($mg, $str, $param, $list) |
734
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
=head2 _yaml_load_string_YAML_XS |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
call _yaml_load_string_YAML_XS method. Expects param $mg to be a Object, param $str to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
$obj->_yaml_load_string_YAML_XS($mg, $str, $param, $list) |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=head2 _yaml_load_string_YAML_PP |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
call _yaml_load_string_YAML_PP method. Expects param $mg to be a Object, param $str to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
$obj->_yaml_load_string_YAML_PP($mg, $str, $param, $list) |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
=head2 yaml_load_file |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
call yaml_load_file method. Expects param $mg to be a Object, param $file to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
$obj->yaml_load_file($mg, $file, $param, $list) |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=head2 _yaml_load_file_YAML |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
call _yaml_load_file_YAML method. Expects param $mg to be a Object, param $file to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
$obj->_yaml_load_file_YAML($mg, $file, $param, $list) |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
=head2 _yaml_load_file_YAML_XS |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
call _yaml_load_file_YAML_XS method. Expects param $mg to be a Object, param $file to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
$obj->_yaml_load_file_YAML_XS($mg, $file, $param, $list) |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
=head2 _yaml_load_file_YAML_PP |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
call _yaml_load_file_YAML_PP method. Expects param $mg to be a Object, param $file to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
$obj->_yaml_load_file_YAML_PP($mg, $file, $param, $list) |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=head2 yaml_write_string |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
call yaml_write_string method. Expects param $mg to be a Object, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
$obj->yaml_write_string($mg, $content, $param, $list) |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
=head2 _yaml_write_string_YAML |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
call _yaml_write_string_YAML method. Expects param $mg to be a Object, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
$obj->_yaml_write_string_YAML($mg, $content, $param, $list) |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=head2 _yaml_write_string_YAML_XS |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
call _yaml_write_string_YAML_XS method. Expects param $mg to be a Object, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
$obj->_yaml_write_string_YAML_XS($mg, $content, $param, $list) |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
=head2 _yaml_write_string_YAML_PP |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
call _yaml_write_string_YAML_PP method. Expects param $mg to be a Object, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
$obj->_yaml_write_string_YAML_PP($mg, $content, $param, $list) |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
=head2 yaml_write_file |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
call yaml_write_file method. Expects param $mg to be a Object, param $file to be a Str, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
$obj->yaml_write_file($mg, $file, $content, $param, $list) |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=head2 _yaml_write_file_YAML |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
call _yaml_write_file_YAML method. Expects param $mg to be a Object, param $file to be a Str, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
$obj->_yaml_write_file_YAML($mg, $file, $content, $param, $list) |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
=head2 _yaml_write_file_YAML_XS |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
call _yaml_write_file_YAML_XS method. Expects param $mg to be a Object, param $file to be a Str, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
$obj->_yaml_write_file_YAML_XS($mg, $file, $content, $param, $list) |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
=head2 _yaml_write_file_YAML_PP |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
call _yaml_write_file_YAML_PP method. Expects param $mg to be a Object, param $file to be a Str, param $content to be a Str, param $param to be a Optional[Str], param $list to be a Optional[Bool]. |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
$obj->_yaml_write_file_YAML_PP($mg, $file, $content, $param, $list) |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=head1 ACCESSORS |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=head2 macro |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
get or set macro. |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
$obj->macro; |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
$obj->macro($value); |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=head1 AUTHOR |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=head1 BUGS |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-hades::macro::yaml at rt.cpan.org>, or through |
836
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Macro-YAML>. I will be notified, and then you'll |
837
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=head1 SUPPORT |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
perldoc Hades::Macro::YAML |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
You can also look for information at: |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
=over 4 |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Macro-YAML> |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Hades-Macro-YAML> |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=item * CPAN Ratings |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Hades-Macro-YAML> |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
=item * Search CPAN |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
L<https://metacpan.org/release/Hades-Macro-YAML> |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
=back |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by LNATION. |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
This is free software, licensed under: |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
=cut |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
|