line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Serializer::YAML; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:SUKRIA'; |
3
|
|
|
|
|
|
|
#ABSTRACT: serializer for handling YAML data |
4
|
|
|
|
|
|
|
$Dancer::Serializer::YAML::VERSION = '1.3521'; |
5
|
165
|
|
|
165
|
|
1156
|
use strict; |
|
165
|
|
|
|
|
367
|
|
|
165
|
|
|
|
|
4817
|
|
6
|
165
|
|
|
165
|
|
878
|
use warnings; |
|
165
|
|
|
|
|
436
|
|
|
165
|
|
|
|
|
3797
|
|
7
|
165
|
|
|
165
|
|
848
|
use Carp; |
|
165
|
|
|
|
|
412
|
|
|
165
|
|
|
|
|
8847
|
|
8
|
165
|
|
|
165
|
|
1272
|
use Dancer::ModuleLoader; |
|
165
|
|
|
|
|
412
|
|
|
165
|
|
|
|
|
5126
|
|
9
|
165
|
|
|
165
|
|
1018
|
use Dancer::Config; |
|
165
|
|
|
|
|
419
|
|
|
165
|
|
|
|
|
7091
|
|
10
|
165
|
|
|
165
|
|
1148
|
use Dancer::Exception qw(:all); |
|
165
|
|
|
|
|
522
|
|
|
165
|
|
|
|
|
20305
|
|
11
|
165
|
|
|
165
|
|
1287
|
use base 'Dancer::Serializer::Abstract'; |
|
165
|
|
|
|
|
394
|
|
|
165
|
|
|
|
|
65791
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# helpers |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub from_yaml { |
16
|
8
|
|
|
8
|
0
|
23
|
my ($yaml) = @_; |
17
|
8
|
|
|
|
|
41
|
my $s = Dancer::Serializer::YAML->new; |
18
|
8
|
|
|
|
|
30
|
$s->deserialize($yaml); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub to_yaml { |
22
|
4
|
|
|
4
|
0
|
14
|
my ($data) = @_; |
23
|
4
|
|
|
|
|
46
|
my $s = Dancer::Serializer::YAML->new; |
24
|
4
|
|
|
|
|
20
|
$s->serialize($data); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# class definition |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub loaded { |
30
|
16
|
|
100
|
16
|
0
|
55
|
my $module = Dancer::Config::settings->{engines}{YAML}{module} || 'YAML'; |
31
|
|
|
|
|
|
|
|
32
|
16
|
50
|
|
|
|
86
|
raise core_serializer => q{Dancer::Serializer::YAML only supports 'YAML' or 'YAML::XS', not $module} |
33
|
|
|
|
|
|
|
unless $module =~ /^YAML(?:::XS)?$/; |
34
|
|
|
|
|
|
|
|
35
|
16
|
50
|
|
|
|
81
|
Dancer::ModuleLoader->load($module) |
36
|
|
|
|
|
|
|
or raise core_serializer => "$module is needed and is not installed"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub init { |
40
|
16
|
|
|
16
|
1
|
37
|
my ($self) = @_; |
41
|
16
|
|
|
|
|
44
|
$self->loaded; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub serialize { |
45
|
12
|
|
|
12
|
1
|
1989
|
my ($self, $entity) = @_; |
46
|
12
|
50
|
|
|
|
34
|
return unless $entity; |
47
|
12
|
|
100
|
|
|
35
|
my $module = Dancer::Config::settings->{engines}{YAML}{module} || 'YAML'; |
48
|
|
|
|
|
|
|
{ |
49
|
165
|
|
|
165
|
|
1449
|
no strict 'refs'; |
|
165
|
|
|
|
|
457
|
|
|
165
|
|
|
|
|
21282
|
|
|
12
|
|
|
|
|
23
|
|
50
|
12
|
|
|
|
|
19
|
&{ $module . '::Dump' }($entity); |
|
12
|
|
|
|
|
436
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub deserialize { |
55
|
12
|
|
|
12
|
1
|
1496
|
my ($self, $content) = @_; |
56
|
12
|
|
100
|
|
|
33
|
my $module = Dancer::Config::settings->{engines}{YAML}{module} || 'YAML'; |
57
|
12
|
100
|
|
|
|
40
|
return unless $content; |
58
|
|
|
|
|
|
|
{ |
59
|
165
|
|
|
165
|
|
1350
|
no strict 'refs'; |
|
165
|
|
|
|
|
477
|
|
|
165
|
|
|
|
|
16057
|
|
|
10
|
|
|
|
|
32
|
|
60
|
10
|
|
|
|
|
20
|
&{ $module . '::Load' }($content); |
|
10
|
|
|
|
|
381
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
6
|
|
|
6
|
1
|
1647
|
sub content_type {'text/x-yaml'} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |