blib/lib/Devel/Cover/DB/IO/Sereal.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 60 CC 2 SCAR 10.6
CC
2
Cov
0%
read
6.0
new
2.0
write
2.0
CRAP 2.9
1 # Copyright 2014-2026, Paul Johnson (paul@pjcj.net)
2  
3 # This software is free. It is licensed under the same terms as Perl itself.
4  
5 # The latest version of this software should be available from my homepage:
6 # https://pjcj.net
7  
8 package Devel::Cover::DB::IO::Sereal;
9  
10 use strict;
11 use warnings;
12  
13 use base "Devel::Cover::DB::IO::Base";
14  
15 use Sereal::Decoder;
16 use Sereal::Encoder;
17  
18 our $VERSION = '1.52'; # VERSION
19  
20 my ($Decoder, $Encoder);
21  
22 sub new {
23 my $class = shift;
24 my $self = $class->SUPER::new(@_);
25 bless $self, $class
26 }
27  
28 sub read {
29 my $self = shift;
30 my ($file) = @_;
31 $self->_read_fh(
32 $file,
33 sub {
34 my ($fh) = @_;
35 local $/;
36 my $data
37 = eval { ($Decoder ||= Sereal::Decoder->new({}))->decode(<$fh>) };
38 die "Can't read $file with Sereal: $@" if $@;
39 $data
40 }
41 )
42 }
43  
44 sub write {
45 my $self = shift;
46 my ($data, $file) = @_;
47 $self->_write_fh(
48 $file,
49 sub {
50 my ($fh) = @_;
51 print $fh ($Encoder ||= Sereal::Encoder->new({}))->encode($data);
52 }
53 )
54 }
55  
56 1
57  
58 __END__