blib/lib/Data/RoundRobinShared.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 50.0% 5 / 10 Conditioncond 21.4% 3 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 71.2% 62 / 87 CC 11 SCAR 25.9
CC
11
Cov
74%
new
21.2
BEGIN
1.0
BEGIN
1.0
CRAP 13.4
↑ Summary
1 package Data::RoundRobinShared;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use IPC::Shareable (':lock');
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.11';
9  
10 use overload
11 1 ▶ 'eq' => \&next,
Subroutine BEGIN: called CC=1 SCAR=0.0
12 'ne' => \&next,
13 1 '""' => \&next;
14  
15 sub new
16 1 ▶{
Subroutine new: called CC=11 SCAR=30.6
Pod documented
17 1 my $class = shift;
18 1 my %params = @_;
19  
20 1 ▶ croak("odd number of arguments passed") if ( @_ % 2 );
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 1 1
21 1 ▶ croak("data needs to be specified") unless ( exists( $params{data} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $params{"data"} 0 1 1
22 1 ▶ croak("data needs to be arrayref") unless ( ref $params{data} eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params{"data"} eq "ARRAY" 0 1 1
23  
24 1 my $self = {};
25  
26 1 ▶ $class = ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
27  
28 1 ▶ my %options = ( key => $params{key} || 'sharedRoundRoundRobin', create => 1, mode => 0644 );
Condition50%1/2
$params{'key'} || 'sharedRoundRoundRobin'
l!l
10
MC/DC0%0/1
$params{'key'} || 'sharedRoundRoundRobin'
$params{'key'}
Truth table50%1/2
A
A= $params{'key'}
Aresult
11
00
29  
30 1 ▶ tie $self->{data}, 'IPC::Shareable', $params{key}, {%options} or croak("server: tie failed");
Branch: 1 branch
BranchTrueFalseTotal
tie $self->{"data"}, "IPC::Shareable", $params{"key"}, {%options} or croak("server: tie failed") 1 0 1
31  
32 0 ▶ if ( !$self->{data} || ( ref $self->{data} eq 'ARRAY' && scalar( @{ $self->{data} } ) != scalar( @{ $params{data} } ) && $params{simple_check} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"data"} or ref $self->{"data"} eq "ARRAY" and scalar @{$self->{"data"};} != scalar @{$params{"data"};} and $params{"simple_check"}) 1 0 1
Condition11%1/9
not $self->{"data"} or ref $self->{"data"} eq "ARRAY" and scalar @{$self->{"data"};} != scalar @{$params{"data"};} and $params{"simple_check"}
l!l&&r!l&&!r
100
ref $self->{"data"} eq "ARRAY" and scalar @{$self->{"data"};} != scalar @{$params{"data"};} and $params{"simple_check"}
!ll&&!rl&&r
000
ref $self->{"data"} eq "ARRAY" and scalar @{$self->{"data"};} != scalar @{$params{"data"};}
!ll&&!rl&&r
000
MC/DC0%0/4
not $self->{"data"} or ref $self->{"data"} eq "ARRAY" and scalar @{$self->{"data"};} != scalar @{$params{"data"};} and $params{"simple_check"}
not $self->{"data"} ref $self->{"data"} eq "ARRAY" scalar @{$self->{"data"};} != scalar @{$params{"data"};} $params{"simple_check"}
Truth table20%1/5
not(A) or B and C and D
A= not $self->{"data"}B= ref $self->{"data"} eq "ARRAY"C= scalar @{$self->{"data"};} != scalar @{$params{"data"};}D= $params{"simple_check"}
ABCDresult
1XXX1
01111
00XX0
010X0
01100
33 {
34 1 ( tied $self->{data} )->shlock(LOCK_EX);
35 1 $self->{data} = [ @{ $params{data} } ];
36 1 ( tied $self->{data} )->shlock(LOCK_UN);
37 }
38  
39 1 return bless $self, $class;
40 }
41  
42 sub next
43 2 ▶{
Subroutine next: called CC=1 SCAR=0.0
Pod documented
44 2 my $self = shift;
45  
46 2 ( tied $self->{data} )->shlock(LOCK_EX);
47  
48 2 my $val = shift( @{ $self->{data} } );
49 2 push( @{ $self->{data} }, $val );
50  
51 2 ( tied $self->{data} )->shlock(LOCK_UN);
52  
53 2 return $val;
54 }
55  
56 sub remove
57 1 ▶{
Subroutine remove: called CC=1 SCAR=0.0
Pod documented
58 1 my $self = shift;
59  
60 1 ( tied $self->{data} )->remove;
61  
62 1 return 1;
63 }
64  
65 1 1;
66  
67 __END__
↑ Summary