File Coverage

blib/lib/Raisin/Encoder/Text.pm
Criterion Covered Total %
statement 18 20 90.0
branch n/a
condition n/a
subroutine 7 8 87.5
pod 0 4 0.0
total 25 32 78.1


line stmt bran cond sub pod time code
1             #!perl
2             #PODNAME: Raisin::Encoder::Text
3             #ABSTRACT: Data::Dumper serialization plugin for Raisin.
4              
5 4     4   1479 use strict;
  4         10  
  4         109  
6 4     4   18 use warnings;
  4         7  
  4         162  
7              
8             package Raisin::Encoder::Text;
9             $Raisin::Encoder::Text::VERSION = '0.94';
10 4     4   559 use Data::Dumper;
  4         5341  
  4         201  
11 4     4   22 use Encode 'encode';
  4         8  
  4         641  
12              
13 51     51 0 166 sub detectable_by { [qw(text/plain txt)] }
14 4     4 0 84 sub content_type { 'text/plain; charset=utf-8' }
15              
16             sub serialize {
17 4     4 0 23 my ($self, $data) = @_;
18              
19 4         37 $data = Data::Dumper->new([$data], ['data'])
20             ->Sortkeys(1)
21             ->Purity(1)
22             ->Terse(1)
23             ->Deepcopy(1)
24             ->Dump;
25 4         403 $data = encode('UTF-8', $data);
26 4         465 $data;
27             }
28              
29             sub deserialize {
30 0     0 0   Raisin::log(error => 'Raisin:Encoder::Text doesn\'t support deserialization');
31 0           die;
32             }
33              
34             1;
35              
36             __END__