Mvalve/Message.pm

filter: Statementstmt 74.5% 41 / 55 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.7% 11 / 17 Podpod 100% 2 / 2 totaltotal 69.2% 54 / 78 CC 3 SCAR 8.2
CC
3
Cov
69%
serialize
6.0
deserialize
6.0
__ANON__
2.0
CRAP 2.3
« Mvalve/State/Memory.pm ↑ Summary Mvalve/Const.pm »
1 # $Id$
2  
3 package Mvalve::Message;
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use MooseX::ClassAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Serializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Digest::SHA1 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use POSIX();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Sys::Hostname();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Time::HiRes();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 class_type 'HTTP::Headers';
15  
16 coerce 'HTTP::Headers'
17 => from 'HashRef',
18 0 ▶ => via { HTTP::Headers->new(%$_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 1 ;
20  
21 has 'id' => (
22 is => 'ro',
23 isa => 'Str',
24 required => 1,
25 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 # XXX - hints as to about when this message was generated
27 0 my ($int_part, $float_part) = split(/\./, Time::HiRes::time());
28 0 my $prefix = join('.', POSIX::strftime('%Y%m%d%H%M%S', localtime($int_part)), $float_part);
29
30 0 return join('-', $prefix, Digest::SHA1::sha1_hex({}, $$, Time::HiRes::time(), rand(), Sys::Hostname::hostname()))
31 }
32 1 );
33  
34 has 'headers' => (
35 is => 'rw',
36 isa => 'HTTP::Headers',
37 coerce => 1,
38 0 ▶ default => sub { HTTP::Headers->new },
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 1 handles => {
40 header => 'header',
41 header_add => 'push_header',
42 header_remove => 'remove_header'
43 },
44 );
45  
46 1 has 'content' => (
47 is => 'rw',
48 );
49  
50 class_has 'SERIALIZER' => (
51 is => 'rw',
52 isa => 'Data::Serializer',
53 lazy => 1,
54 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
55 0 Data::Serializer->new(
56 serializer => 'Storable',
57 compress => 1,
58 )
59 },
60 1 );
61  
62 1 __PACKAGE__->meta->make_immutable;
63  
64 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 1 ▶no MooseX::ClassAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 0 ▶sub serialize {
Subroutine serialize: not called CC=2 SCAR=17.9
Pod documented
68 0 my $rv = eval { $_[0]->SERIALIZER->serialize($_[0]) };
69 0 ▶ Carp::confess("Failed to serialize @_: $@") if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
70 0 return $rv;
71 }
72
73 0 ▶sub deserialize {
Subroutine deserialize: not called CC=2 SCAR=17.9
Pod documented
74 0 my $rv = eval { shift->SERIALIZER->deserialize(@_) };
75 0 ▶ Carp::confess("Failed to deserialize @_: $@") if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
76 0 return $rv;
77 }
78  
79  
80 1 1;
81  
82 __END__
« Mvalve/State/Memory.pm ↑ Summary Mvalve/Const.pm »