Message/Queue/DQS.pm

filter: Statementstmt 41.0% 16 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 41.8% 23 / 55 CC 4 SCAR 16.9
CC
4
Cov
36%
new
12.0
add_message
6.0
get_message
2.0
CRAP 5.4
« Message/Generator.pm ↑ Summary Message/Queue/NULL.pm »
1 #+##############################################################################
2 # #
3 # File: Messaging/Message/Queue/DQS.pm #
4 # #
5 # Description: abstraction of a Directory::Queue::Simple message queue #
6 # #
7 #-##############################################################################
8  
9 #
10 # module definition
11 #
12  
13 package Messaging::Message::Queue::DQS;
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 our $VERSION = "1.7";
17 1 our $REVISION = sprintf("%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/);
18  
19 #
20 # inheritance
21 #
22  
23 1 our @ISA = qw(Messaging::Message::Queue Directory::Queue::Simple);
24  
25 #
26 # used modules
27 #
28  
29 1 ▶use Messaging::Message qw(_require);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Params::Validate qw(validate_with validate_pos :types);
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 #
33 # constructor
34 #
35  
36 0 ▶sub new : method {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
37 0 my($class, %option, $compression, $self);
38  
39 0 _require("Directory::Queue::Simple");
40 0 $class = shift(@_);
41 0 %option = validate_with(
42 params => \@_,
43 spec => { compression => { type => SCALAR, optional => 1 } },
44 allow_extra => 1,
45 );
46 0 $compression = delete($option{compression});
47 0 ▶ if ($compression) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compression) 0 0 0
48 # check that this compression is indeed available...
49 0 Messaging::Message->new()->jsonify(compression => $compression);
50 }
51 0 $self = Directory::Queue::Simple->new(%option);
52 0 ▶ if ($compression) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compression) 0 0 0
53 # extend the object the dirty way...
54 0 $self->{compression} = $compression;
55 }
56 0 bless($self, $class);
57 0 return($self);
58 }
59  
60 #
61 # add a message object to the queue
62 #
63  
64 0 ▶sub add_message : method {
Subroutine add_message: not called CC=2 SCAR=17.9
Pod documented
65 0 my($self, $msg, %opt);
66  
67 0 $self = shift(@_);
68 0 validate_pos(@_, { isa => "Messaging::Message" });
69 0 $msg = shift(@_);
70 0 ▶ %opt = (compression => $self->{compression}) if $self->{compression};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"compression"} 0 0 0
71 0 return($self->add_ref($msg->serialize_ref(%opt)));
72 }
73  
74 #
75 # get a message object from the queue
76 #
77  
78 0 ▶sub get_message : method {
Subroutine get_message: not called CC=1 SCAR=6.9
Pod documented
79 0 my($self, $elt);
80  
81 0 $self = shift(@_);
82 0 validate_pos(@_, { type => SCALAR });
83 0 $elt = shift(@_);
84 0 return(Messaging::Message->deserialize_ref($self->get_ref($elt)));
85 }
86  
87 1 1;
88  
89 __DATA__
« Message/Generator.pm ↑ Summary Message/Queue/NULL.pm »