Multiplex.pm

filter: Statementstmt 57.9% 51 / 88 Branchbran 34.6% 9 / 26 Conditioncond 15.3% 2 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 72.2% 13 / 18 Podpod 83.3% 10 / 12 totaltotal 51.5% 85 / 165 CC 30 SCAR 25.1
CC
30
Cov
49%
set
42.0
load
20.0
save
20.0
CRAP 12.3
« SVGout.pm ↑ Summary Text.pm »
1 # Copyright 2010, 2011, 2012 Kevin Ryde
2  
3 # This file is part of Image-Base-Other.
4 #
5 # Image-Base-Other is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Image-Base-Other is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Image-Base-Other. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 package Image::Base::Multiplex;
20 2 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use vars '$VERSION', '@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 $VERSION = 9;
26  
27 2 ▶use Image::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 @ISA = ('Image::Base');
29  
30 # uncomment this to run the ### lines
31 #use Smart::Comments;
32  
33  
34 6 ▶sub new {
Subroutine new: called CC=2 SCAR=7.6
Pod documented
35 6 my $class = shift;
36  
37 6 ▶ if (ref $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $class) 0 6 6
38 # clone by copying fields, don't think need to copy images array
39 0 return bless { %$class }, $class;
40 }
41  
42 6 return bless { -images => [],
43 @_ }, $class;
44 }
45  
46 1153 ▶sub _get {
Subroutine _get: called CC=3 SCAR=11.0
47 1153 my ($self, $key) = @_;
48 # ### Image-Base-Multiplex _get(): $key
49 1153 ▶ if ($key eq '-images') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq '-images') { } 3 1150 1153
50 3 return $self->SUPER::_get($key);
51 } else {
52 1150 ▶ my $image = $self->{'-images'}->[0] || return undef;
Condition50%1/2
$self->{'-images'}[0] || (return undef)
l!l
11500
MC/DC0%0/1
$self->{'-images'}[0] || (return undef)
$self->{'-images'}[0]
Truth table50%1/2
A
A= $self->{'-images'}[0]
Aresult
11
00
53 1150 return $image->get($key);
54 }
55 }
56 0 ▶sub set {
Subroutine set: not called CC=6 SCAR=37.4
Pod documented
57 0 my $self = shift;
58 # ### Image-Base-Multiplex set()
59  
60 0 my $set_file;
61 0 ▶ for (my $i = 0; $i < @_; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 0 0 0
62 0 my $key = $_[$i];
63 0 $set_file = ($key eq '-file');
64 0 ▶ if ($key eq '-images') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq '-images') { } 0 0 0
65 0 $self->{$key} = $_[$i+1];
66 0 splice @_, $i, 2;
67 } else {
68 0 $i += 2
69 }
70 }
71  
72 0 my $images = $self->{'-images'};
73 0 ▶ if ($set_file && @$images > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set_file and @$images > 1) 0 0 0
Condition0%0/3
$set_file and @$images > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$set_file and @$images > 1
$set_file @$images > 1
Truth table0%0/3
A and B
A= $set_fileB= @$images > 1
ABresult
0X0
100
111
74 0 croak 'Refusing to set multiple images to same -file';
75 }
76  
77 0 foreach my $image (@$images) {
78 0 $image->set(@_);
79 }
80 }
81  
82 0 ▶sub load {
Subroutine load: not called CC=4 SCAR=30.0
Pod documented
83 0 my $self = shift;
84 0 my $images = $self->{'-images'};
85 0 ▶ if (@_ && @$images > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and @$images > 1) 0 0 0
Condition0%0/3
@_ and @$images > 1
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and @$images > 1
@_ @$images > 1
Truth table0%0/3
A and B
A= @_B= @$images > 1
ABresult
0X0
100
111
86 0 croak 'Refusing to load multiple images from one file';
87 }
88 0 foreach my $image (@$images) { $image->load; }
89 }
90 0 ▶sub save {
Subroutine save: not called CC=4 SCAR=30.0
Pod documented
91 0 my $self = shift;
92 0 my $images = $self->{'-images'};
93 0 ▶ if (@_ && @$images > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and @$images > 1) 0 0 0
Condition0%0/3
@_ and @$images > 1
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and @$images > 1
@_ @$images > 1
Truth table0%0/3
A and B
A= @_B= @$images > 1
ABresult
0X0
100
111
94 0 croak 'Refusing to save multiple images to one file';
95 }
96 0 foreach my $image (@$images) { $image->save; }
97 }
98  
99 2914 ▶sub xy {
Subroutine xy: called CC=4 SCAR=13.9
Pod documented
100 2914 my $self = shift;
101 ### Image-Base-Multiplex xy(): @_[1..$#_]
102 2914 my $images = $self->{'-images'};
103 2914 ▶ if (@_ > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) { } 8 2906 2914
104 8 foreach my $image (@$images) { $image->xy(@_); }
105 } else {
106 2906 my ($x, $y) = @_;
107 2906 ▶ my $image = $images->[0] || return undef;
Condition50%1/2
$images->[0] || (return undef)
l!l
29060
MC/DC0%0/1
$images->[0] || (return undef)
$images->[0]
Truth table50%1/2
A
A= $images->[0]
Aresult
11
00
108 2906 return $image->xy($x,$y);
109 }
110 }
111 26 ▶sub line {
Subroutine line: called CC=2 SCAR=6.9
Pod documented
112 26 foreach my $image (@{shift->{'-images'}}) { $image->line(@_); }
113 }
114 136 ▶sub rectangle {
Subroutine rectangle: called CC=2 SCAR=6.9
Pod documented
115 136 foreach my $image (@{shift->{'-images'}}) { $image->rectangle(@_); }
116 }
117 26 ▶sub ellipse {
Subroutine ellipse: called CC=2 SCAR=6.9
Pod documented
118 26 foreach my $image (@{shift->{'-images'}}) { $image->ellipse(@_); }
119 }
120 0 ▶sub diamond {
Subroutine diamond: not called CC=2 SCAR=17.9
Pod documented
121 0 foreach my $image (@{shift->{'-images'}}) { $image->diamond(@_); }
122 }
123  
124 3 ▶sub add_colours {
Subroutine add_colours: called CC=3 SCAR=11.1
Pod documented
125 3 foreach my $image (@{shift->{'-images'}}) {
126 3 ▶ if (my $coderef = $image->can('add_colours')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $coderef = $image->can("add_colours")) 3 0 3
127 3 $image->$coderef(@_);
128 }
129 }
130 }
131  
132 0 ▶sub Image_Base_Other_xy_points {
Subroutine Image_Base_Other_xy_points: not called CC=4 SCAR=30.0
Pod undocumented
133 ### Multiplex xy_points
134 0 foreach my $image (@{shift->{'-images'}}) {
135 0 ▶ if (my $coderef = $image->can('Image_Base_Other_xy_points')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $coderef = $image->can('Image_Base_Other_xy_points')) { } 0 0 0
136 0 $image->$coderef(@_);
137 } else {
138 0 ▶ for (my $i = 1; $i < @_; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 0 0 0
139 0 $image->xy ($_[$i], $_[$i+1],
140 $_[0]); # colour
141 }
142 }
143 }
144 }
145 32 ▶sub Image_Base_Other_rectangles {
Subroutine Image_Base_Other_rectangles: called CC=4 SCAR=14.2
Pod undocumented
146 ### Multiplex rectangles
147 32 foreach my $image (@{shift->{'-images'}}) {
148 32 ▶ if (my $coderef = $image->can('Image_Base_Other_rectangles')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $coderef = $image->can('Image_Base_Other_rectangles')) { } 0 32 32
149 0 $image->$coderef(@_);
150 } else {
151 32 ▶ for (my $i = 2; $i < @_; $i += 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_) 32 32 64
152 ### rect: @_[$i .. $i+3], $_[0], $_[1]
153 32 $image->rectangle (@_[$i .. $i+3],
154 $_[0], # colour
155 $_[1]); # fill
156 }
157 }
158 }
159 }
160  
161 2 1;
162 __END__
« SVGout.pm ↑ Summary Text.pm »