| 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.1'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
68081
|
use strict; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
211
|
|
|
7
|
6
|
|
|
6
|
|
38
|
use warnings; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
212
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
4007
|
use List::MoreUtils qw/ any all /; |
|
|
6
|
|
|
|
|
64719
|
|
|
|
6
|
|
|
|
|
58
|
|
|
10
|
6
|
|
|
6
|
|
11343
|
use Module::Info; |
|
|
6
|
|
|
|
|
43378
|
|
|
|
6
|
|
|
|
|
242
|
|
|
11
|
6
|
|
|
6
|
|
50
|
use Module::Runtime qw/ use_module /; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
50
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
377
|
use Role::Tiny; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
52
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires 'extensions'; # first extension is the canonical one |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
requires 'serialize', 'deserialize'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
672
|
|
|
672
|
1
|
1602
|
sub precedence { 100 } |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub required_modules { |
|
22
|
732
|
|
|
732
|
1
|
1192
|
my $package = shift; |
|
23
|
732
|
|
|
|
|
3336
|
$package =~ s/^File::Serialize::Serializer:://r; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
4
|
|
|
4
|
0
|
1198
|
sub extension { ($_[0]->extensions)[0] } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub does_extension { |
|
29
|
137
|
|
|
137
|
0
|
295
|
my( $self, $ext ) = @_; |
|
30
|
137
|
100
|
|
|
|
313
|
return unless $ext; |
|
31
|
133
|
|
|
178
|
|
566
|
return any { $_ eq $ext } $self->extensions; |
|
|
178
|
|
|
|
|
660
|
|
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub is_operative { |
|
35
|
387
|
50
|
|
387
|
0
|
34845
|
return 1 unless $_[0]->required_modules; |
|
36
|
387
|
|
|
430
|
|
1680
|
all { Module::Info->new_from_module($_) } $_[0]->required_modules; |
|
|
430
|
|
|
|
|
11446
|
|
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub groom_serialize_options { |
|
40
|
24
|
|
|
24
|
1
|
45
|
my $self = shift; |
|
41
|
24
|
|
|
|
|
81
|
$self->groom_options(@_); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub groom_deserialize_options { |
|
45
|
23
|
|
|
23
|
1
|
49
|
my $self = shift; |
|
46
|
23
|
|
|
|
|
78
|
$self->groom_options(@_); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub groom_options { |
|
50
|
10
|
|
|
10
|
1
|
21
|
my $self = shift; |
|
51
|
10
|
|
|
|
|
41
|
@_; |
|
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
|
47
|
|
|
47
|
0
|
5534
|
my $self = shift; |
|
69
|
47
|
|
|
|
|
136
|
use_module($_) for $self->required_modules; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |