File Coverage

blib/lib/DR/Msgpuck.pm
Criterion Covered Total %
statement 31 39 79.4
branch 4 6 66.6
condition 1 3 33.3
subroutine 12 16 75.0
pod n/a
total 48 64 75.0


line stmt bran cond sub pod time code
1 3     3   78106 use 5.014002;
  3         8  
2 3     3   9 use strict;
  3         3  
  3         44  
3 3     3   7 use warnings;
  3         7  
  3         343  
4              
5             package DR::Msgpuck::Bool;
6              
7              
8             use overload
9 0     0   0 bool => sub { ${ $_[0] } },
  0         0  
10 0     0   0 int => sub { ${ $_[0] } },
  0         0  
11 0     0   0 '!' => sub { $_[0]->new(!${ $_[0] }) },
  0         0  
12 4     4   1498 '""' => sub { ${ $_[0] } },
  4         16  
13 3     3   1807 ;
  3         2660  
  3         32  
14              
15             sub TO_JSON {
16 0     0   0 my ($self) = @_;
17 0 0       0 $$self ? 'true' : 'false';
18             }
19              
20             sub TO_MSGPACK {
21 10     10   12062 my ($self) = @_;
22 10 100       348 pack 'C', $$self ? 0xC3 : 0xC2;
23             }
24              
25             sub new {
26 6     6   9 my ($class, $v) = @_;
27 6 100       14 $v = $v ? 1 : 0;
28 6   33     72 bless \$v => ref($class) || $class;
29             }
30              
31             package DR::Msgpuck::True;
32 3     3   502 use base 'DR::Msgpuck::Bool';
  3         4  
  3         1186  
33              
34             sub new {
35 3     3   1241 my ($class) = @_;
36 3         24 $class->SUPER::new(1);
37             }
38              
39             package DR::Msgpuck::False;
40 3     3   16 use base 'DR::Msgpuck::Bool';
  3         2  
  3         783  
41              
42             sub new {
43 3     3   656 my ($class) = @_;
44 3         14 $class->SUPER::new(0);
45             }
46              
47              
48             package DR::Msgpuck;
49             require Exporter;
50 3     3   1455 use AutoLoader qw(AUTOLOAD);
  3         3163  
  3         12  
51              
52             our @ISA = qw(Exporter);
53             our @EXPORT_OK = qw(msgpack msgunpack msgunpack_utf8);
54             our @EXPORT = @EXPORT_OK;
55             our $VERSION = '0.02';
56              
57             require XSLoader;
58             XSLoader::load('DR::Msgpuck', $VERSION);
59              
60             1;
61             __END__