Message/Queue/DQN.pm

filter: Statementstmt 35.5% 16 / 45 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 36.5% 23 / 63 CC 5 SCAR 21.9
CC
5
Cov
30%
get_message
20.0
add_message
6.0
new
2.0
CRAP 8.9
↑ Summary Message.pm »
1 #+##############################################################################
2 # #
3 # File: Messaging/Message/Queue/DQN.pm #
4 # #
5 # Description: abstraction of a Directory::Queue::Normal message queue #
6 # #
7 #-##############################################################################
8  
9 #
10 # module definition
11 #
12  
13 package Messaging::Message::Queue::DQN;
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.6 $ =~ /(\d+)\.(\d+)/);
18  
19 #
20 # inheritance
21 #
22  
23 1 our @ISA = qw(Messaging::Message::Queue Directory::Queue::Normal);
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=1 SCAR=6.9
Pod documented
37 0 my($class, %option, $self);
38  
39 0 _require("Directory::Queue::Normal");
40 0 $class = shift(@_);
41 0 %option = validate_with(
42 params => \@_,
43 spec => {},
44 allow_extra => 1,
45 );
46 $option{schema} = {
47 0 header => "table",
48 binary => "binary*?",
49 text => "string*?",
50 };
51 0 $self = Directory::Queue::Normal->new(%option);
52 0 bless($self, $class);
53 0 return($self);
54 }
55  
56 #
57 # add a message object to the queue
58 #
59  
60 0 ▶sub add_message : method {
Subroutine add_message: not called CC=2 SCAR=17.9
Pod documented
61 0 my($self, $msg, %data);
62  
63 0 $self = shift(@_);
64 0 validate_pos(@_, { isa => "Messaging::Message" });
65 0 $msg = shift(@_);
66 0 $data{header} = $msg->header();
67 0 ▶ $data{$msg->text() ? "text" : "binary"} = $msg->body_ref();
Branch: 1 branch
BranchTrueFalseTotal
$msg->text ? : 0 0 0
68 0 return($self->add(\%data));
69 }
70  
71 #
72 # get a message object from the queue
73 #
74  
75 0 ▶sub get_message : method {
Subroutine get_message: not called CC=4 SCAR=30.0
Pod documented
76 0 my($self, $elt, $data, $msg);
77  
78 0 $self = shift(@_);
79 0 validate_pos(@_, { type => SCALAR });
80 0 $elt = shift(@_);
81 0 $data = $self->get($elt);
82 0 $msg = Messaging::Message->new();
83 0 ▶ $msg->header($data->{header}) if keys(%{ $data->{header} });
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$$data{"header"};} 0 0 0
84 0 ▶ if (exists($data->{text})) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $data->{'text'}) { } 0 0 0
elsif (exists $data->{'binary'}) { } 0 0 0
85 0 $msg->body_ref($data->{text});
86 0 $msg->text(1);
87 } elsif (exists($data->{binary})) {
88 0 $msg->body_ref($data->{binary});
89 0 $msg->text(0);
90 }
91 0 return($msg);
92 }
93  
94 1 1;
95  
96 __DATA__
↑ Summary Message.pm »