Q4M/Status.pm

filter: Statementstmt 39.3% 13 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 38.3% 18 / 47 CC 5 SCAR 24.9
CC
5
Cov
33%
fetch
23.0
__ANON__
2.0
BEGIN
1.0
CRAP 12.1
« Q4M.pm ↑ Summary
1 # $Id$
2  
3 package Queue::Q4M::Status;
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub fetch {
Subroutine fetch: not called CC=5 SCAR=31.4
Pod documented
9 # Black magic. Since I don't know if the parameters will be the same
10 # for every future release of Q4M, I'll just create a cached
11 # anonymous class via moose. Wicked!
12  
13 0 my $class = shift;
14 0 ▶ my $dbh = shift || Carp::confess("Q4M requires a database handle");
Condition0%0/2
shift() || Carp::confess('Q4M requires a database handle')
l!l
00
MC/DC0%0/1
shift() || Carp::confess('Q4M requires a database handle')
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
15  
16 0 my $sth = $dbh->prepare( "SHOW ENGINE QUEUE STATUS" );
17  
18 0 $sth->execute();
19 0 my %attributes;
20  
21 0 my ($dummy1, $dummy2, $status);
22 0 $sth->bind_columns(\($dummy1, $dummy2, $status));
23 0 $sth->fetchrow_arrayref;
24 0 $sth->finish;
25  
26 # now parse the status
27 0 ▶ { no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
28 0 foreach my $line (split(/\r?\n/, $status)) {
29 0 ▶ next unless $line =~ /^([\w_]+)\s+(\d+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /^([\w_]+)\s+(\d+)$/ 0 0 0
30  
31 0 my ($name, $value) = ($1, $2);
32 0 ▶ if (! defined &{$class.'::'.$name}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &{$class . '::' . $name;}) 0 0 0
33 0 ▶ *{$class.'::'.$name} = sub { shift->{$name} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 }
35 0 $attributes{$1} = $2;
36 }
37 }
38 0 return bless {%attributes}, $class;
39 }
40  
41 3 1;
42  
43 __END__
« Q4M.pm ↑ Summary