line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
262322
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
82
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
129
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Paludis::ResumeState::Serialization; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
2
|
|
|
2
|
|
69
|
$Paludis::ResumeState::Serialization::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$Paludis::ResumeState::Serialization::VERSION = '0.01000410'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Work with resume-files generated by Paludis |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1356
|
use Paludis::ResumeState::Serialization::Grammar; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
102
|
|
15
|
2
|
|
|
2
|
|
2154
|
use Class::Load 0.06 qw(); |
|
2
|
|
|
|
|
189303
|
|
|
2
|
|
|
|
|
65
|
|
16
|
2
|
|
|
2
|
|
21
|
use Params::Util qw( _HASHLIKE _STRING); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
185
|
|
17
|
2
|
|
|
2
|
|
12
|
use Carp qw(); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
36
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
1760
|
no autovivification; |
|
2
|
|
|
|
|
2180
|
|
|
2
|
|
|
|
|
12
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _get_content { |
22
|
6
|
|
|
6
|
|
17
|
my ($config) = shift; |
23
|
6
|
50
|
|
|
|
69
|
return $config->{content} if _STRING( $config->{content} ); |
24
|
0
|
0
|
|
|
|
0
|
Carp::croak('{ content => } must be a scalar ') |
25
|
|
|
|
|
|
|
if defined $config->{content}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _serializer { |
32
|
9
|
|
|
9
|
|
29
|
my ($name) = shift; |
33
|
9
|
|
|
|
|
41
|
my $formats = { |
34
|
|
|
|
|
|
|
'basic' => __PACKAGE__ . '::Basic', |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# 'simple_objects' => __PACKAGE__ . '::MockObjects', |
37
|
|
|
|
|
|
|
# 'full_objects' => __PACKAGE__ . '::FullObjects', |
38
|
|
|
|
|
|
|
}; |
39
|
9
|
|
|
|
|
23
|
my $formatnames = join q{,}, keys %{$formats}; |
|
9
|
|
|
|
|
70
|
|
40
|
|
|
|
|
|
|
|
41
|
9
|
50
|
33
|
|
|
105
|
Carp::croak("Format Name must be a string ( in [$formatnames] ), not undef or a ref") |
42
|
|
|
|
|
|
|
unless defined $name and _STRING($name); |
43
|
|
|
|
|
|
|
|
44
|
9
|
50
|
|
|
|
93
|
Carp::croak("Format $name not in $formatnames ") unless exists $formats->{$name}; |
45
|
9
|
|
|
|
|
65
|
Class::Load::load_class( $formats->{$name} ); |
46
|
9
|
|
|
|
|
925
|
return $formats->{$name}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub deserialize { |
52
|
6
|
|
|
6
|
1
|
22864
|
my ( $self, $config ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
6
|
50
|
|
|
|
55
|
Carp::croak( 'deserialize needs a configuration hash passed to it.' . qq{\n} . 'please see perldoc for details' ) |
55
|
|
|
|
|
|
|
unless _HASHLIKE($config); |
56
|
|
|
|
|
|
|
|
57
|
6
|
|
|
|
|
28
|
my $content = _get_content($config); |
58
|
|
|
|
|
|
|
|
59
|
6
|
50
|
|
|
|
33
|
Carp::croak('Can\'t deserialize, no content provided, provide deserialize( hash ) with content => ') |
60
|
|
|
|
|
|
|
unless defined $content; |
61
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
30
|
return _serializer( $config->{format} )->deserialize( $config->{content} ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub serialize { |
67
|
3
|
|
|
3
|
1
|
12645
|
my ( $self, $config ) = @_; |
68
|
3
|
|
|
|
|
24
|
return _serializer( $config->{format} )->serialize( $config->{data} ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |