| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Serialize::Serializer; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Role for defining File::Serialize serializers |
|
4
|
|
|
|
|
|
|
$File::Serialize::Serializer::VERSION = '1.5.0'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
63352
|
use strict; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
193
|
|
|
7
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
|
7
|
|
|
|
|
25
|
|
|
|
7
|
|
|
|
|
193
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
3517
|
use List::MoreUtils qw/ any all /; |
|
|
7
|
|
|
|
|
61804
|
|
|
|
7
|
|
|
|
|
85
|
|
|
10
|
7
|
|
|
7
|
|
10847
|
use Module::Info; |
|
|
7
|
|
|
|
|
41982
|
|
|
|
7
|
|
|
|
|
221
|
|
|
11
|
7
|
|
|
7
|
|
44
|
use Module::Runtime qw/ use_module /; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
48
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
7
|
|
|
7
|
|
373
|
use Role::Tiny; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
48
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires 'extensions'; # first extension is the canonical one |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
requires 'serialize', 'deserialize'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1344
|
|
|
1344
|
1
|
2671
|
sub precedence { 100 } |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub required_modules { |
|
22
|
849
|
|
|
849
|
1
|
1191
|
my $package = shift; |
|
23
|
849
|
|
|
|
|
3325
|
$package =~ s/^File::Serialize::Serializer:://r; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
5
|
|
|
5
|
0
|
1173
|
sub extension { ($_[0]->extensions)[0] } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub does_extension { |
|
29
|
208
|
|
|
208
|
0
|
430
|
my( $self, $ext ) = @_; |
|
30
|
208
|
100
|
|
|
|
404
|
return unless $ext; |
|
31
|
203
|
|
|
290
|
|
880
|
return any { $_ eq $ext } $self->extensions; |
|
|
290
|
|
|
|
|
824
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_operative { |
|
35
|
513
|
100
|
|
513
|
0
|
32085
|
return 1 unless $_[0]->required_modules; |
|
36
|
456
|
|
|
513
|
|
1708
|
all { Module::Info->new_from_module($_) } $_[0]->required_modules; |
|
|
513
|
|
|
|
|
12629
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub groom_serialize_options { |
|
40
|
29
|
|
|
29
|
1
|
51
|
my $self = shift; |
|
41
|
29
|
|
|
|
|
105
|
$self->groom_options(@_); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub groom_deserialize_options { |
|
45
|
34
|
|
|
34
|
1
|
61
|
my $self = shift; |
|
46
|
34
|
|
|
|
|
119
|
$self->groom_options(@_); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub groom_options { |
|
50
|
26
|
|
|
26
|
1
|
51
|
my $self = shift; |
|
51
|
26
|
|
|
|
|
113
|
@_; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
before serialize => \&init; |
|
55
|
|
|
|
|
|
|
before deserialize => \&init; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
around serialize => sub { |
|
58
|
|
|
|
|
|
|
my( $orig, $self, $data, $options ) = @_; |
|
59
|
|
|
|
|
|
|
$orig->( $self, $data, $self->groom_serialize_options($options) ); |
|
60
|
|
|
|
|
|
|
}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
around deserialize => sub { |
|
63
|
|
|
|
|
|
|
my( $orig, $self, $data, $options ) = @_; |
|
64
|
|
|
|
|
|
|
$orig->( $self, $data, $self->groom_deserialize_options($options) ); |
|
65
|
|
|
|
|
|
|
}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub init { |
|
68
|
63
|
|
|
63
|
0
|
5502
|
my $self = shift; |
|
69
|
63
|
|
|
|
|
185
|
use_module($_) for $self->required_modules; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |