blib/lib/Data/Serializer/Sereal.pm

filter: Statementstmt 54.2% 19 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 5 / 10 Podpod 100% 4 / 4 totaltotal 44.4% 28 / 63 CC 5 SCAR 17.8
CC
5
Cov
42%
decoder
12.0
encoder
12.0
serialize
2.0
CRAP 5.9
↑ Summary
1 package Data::Serializer::Sereal;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw(Data::Serializer);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Sereal::Encoder qw(sereal_encode_with_object);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Sereal::Decoder qw(sereal_decode_with_object);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Data::Serializer::Sereal - Creates bridge between Data::Serializer and Sereal
12  
13 =head1 VERSION
14  
15 Version 1.05
16  
17 =cut
18  
19 2 our $VERSION = '1.05';
20  
21 2 our $ENCODER;
22 2 our $DECODER;
23  
24  
25 =head1 SYNOPSIS
26  
27 Creates bridge between Data::Serializer and Sereal
28  
29 =head1 SUBROUTINES/METHODS
30  
31 =head2 serialize
32  
33 serialize object/data
34  
35 =cut
36  
37 0 ▶sub serialize {
Subroutine serialize: not called CC=1 SCAR=6.9
Pod documented
38 0 my ($self, $object) = @_;
39 0 return sereal_encode_with_object($self->encoder, $object);
40 }
41  
42 =head2 deserialize
43  
44 deserialize object/data
45  
46 =cut
47  
48 0 ▶sub deserialize {
Subroutine deserialize: not called CC=1 SCAR=6.9
Pod documented
49 0 my ($self) = @_;
50 0 my $object;
51 0 sereal_decode_with_object($self->decoder, $_[1], $object);
52 0 return $object;
53 }
54  
55 =head2 decoder
56  
57 gets the decoder from options or uses the default decoder
58  
59 =cut
60  
61 0 ▶sub decoder {
Subroutine decoder: not called CC=3 SCAR=24.8
Pod documented
62 0 my ($self) = @_;
63 0 my $decoder = $self->{options}{decoder};
64 0 ▶ return $decoder if ref($decoder) eq 'Sereal::Decoder';
Branch: 1 branch
BranchTrueFalseTotal
if ref $decoder eq "Sereal::Decoder" 0 0 0
65 0 ▶ return $DECODER ||= Sereal::Decoder->new();
Condition0%0/3
$Data::Serializer::Sereal::DECODER ||= "Sereal::Decoder"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$Data::Serializer::Sereal::DECODER ||= "Sereal::Decoder"->new
$Data::Serializer::Sereal::DECODER "Sereal::Decoder"->new
Truth table0%0/3
A ||= B
A= $Data::Serializer::Sereal::DECODERB= "Sereal::Decoder"->new
ABresult
1X1
011
000
66 }
67  
68 =head2 encoder
69  
70 gets the encoder from options or uses the default encoder
71  
72 =cut
73  
74 0 ▶sub encoder {
Subroutine encoder: not called CC=3 SCAR=24.8
Pod documented
75 0 my ($self) = @_;
76 0 my $encoder = $self->{options}{encoder};
77 0 ▶ return $encoder if ref($encoder) eq 'Sereal::Encoder';
Branch: 1 branch
BranchTrueFalseTotal
if ref $encoder eq "Sereal::Encoder" 0 0 0
78 0 ▶ return $ENCODER ||= Sereal::Encoder->new();
Condition0%0/3
$Data::Serializer::Sereal::ENCODER ||= "Sereal::Encoder"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$Data::Serializer::Sereal::ENCODER ||= "Sereal::Encoder"->new
$Data::Serializer::Sereal::ENCODER "Sereal::Encoder"->new
Truth table0%0/3
A ||= B
A= $Data::Serializer::Sereal::ENCODERB= "Sereal::Encoder"->new
ABresult
1X1
011
000
79 }
80  
81 =head2
82  
83 Recreates global ENCODER/DECODER after thread is created
84  
85 =cut
86  
87 0 ▶sub CLONE {
Subroutine CLONE: not called CC=1 SCAR=6.9
88 0 $ENCODER = undef;
89 0 $DECODER = undef;
90 }
91  
92 =head1 AUTHOR
93  
94 James Rouzier, C<< <rouzier at gmail.com> >>
95  
96 =head1 BUGS
97  
98 Please report any bugs or feature requests to C<bug-data-serializer-sereal at rt.cpan.org>, or through
99 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Serializer-Sereal>. I will be notified, and then you'll
100 automatically be notified of progress on your bug as I make changes.
101  
102  
103  
104  
105 =head1 SUPPORT
106  
107 You can find documentation for this module with the perldoc command.
108  
109 perldoc Data::Serializer::Sereal
110  
111  
112 You can also look for information at:
113  
114 =over 4
115  
116 =item * RT: CPAN's request tracker
117  
118 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-Serializer-Sereal>
119  
120 =item * AnnoCPAN: Annotated CPAN documentation
121  
122 L<http://annocpan.org/dist/Data-Serializer-Sereal>
123  
124 =item * CPAN Ratings
125  
126 L<http://cpanratings.perl.org/d/Data-Serializer-Sereal>
127  
128 =item * Search CPAN
129  
130 L<http://search.cpan.org/dist/Data-Serializer-Sereal/>
131  
132 =back
133  
134  
135  
136 =head1 LICENSE AND COPYRIGHT
137  
138 Copyright 2014 James Rouzier.
139  
140 This program is free software; you can redistribute it and/or modify it
141 under the terms of either: the GNU General Public License as published
142 by the Free Software Foundation; or the Artistic License.
143  
144 See http://dev.perl.org/licenses/ for more information.
145  
146  
147 =cut
148  
149 2 1; # End of Data::Serializer::Sereal
↑ Summary