blib/lib/LibWeb/Class.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 66.6% 8 / 12 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 80.0% 4 / 5 Podpod 50.0% 1 / 2 totaltotal 72.8% 43 / 59 CC 11 SCAR 20.8
CC
11
Cov
79%
rearrange
11.3
new
2.3
BEGIN
1.0
CRAP 8.0
« blib/lib/LibWeb/File.pm ↑ Summary blib/lib/LibWeb/Time.pm »
1 #==============================================================================
2 # LibWeb::Class -- A base class for libweb modules.
3  
4 package LibWeb::Class;
5  
6 # Copyright (C) 2000 Colin Kong
7 #
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #=============================================================================
22  
23 # $Id: Class.pm,v 1.4 2000/07/18 06:33:30 ckyc Exp $
24  
25 #-#############################
26 # Use standard library.
27 6 require 5.004;
28 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 6 $VERSION = '0.02';
32  
33 #-#############################
34 # Methods.
35 1 ▶sub new {
Subroutine new: called CC=2 SCAR=8.1
Pod undocumented
36 1 my $class = shift;
37 1 ▶ bless( {}, 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
38 }
39  
40 0 ▶sub DESTROY {}
Subroutine DESTROY: not called CC=1 SCAR=0.0
41  
42 7 ▶sub rearrange {
Subroutine rearrange: called CC=10 SCAR=24.3
Pod documented
43 #
44 # Stolen from CGI.pm and modified.
45 #
46 # Smart rearrangement of parameters to allow named parameter
47 # calling. We do the rearrangement if:
48 # 1. The first parameter begins with a -
49 #
50 7 my($self,$order,@param) = @_;
51 7 ▶ return () unless @param;
Branch: 1 branch
BranchTrueFalseTotal
unless @param 5 2 7
52  
53 2 ▶ if (ref($param[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $param[0] eq 'HASH') { } 0 2 2
54 0 @param = %{$param[0]};
55 } else {
56 return @param
57 2 ▶ unless (defined($param[0]) && substr($param[0],0,1) eq '-');
Branch: 1 branch
BranchTrueFalseTotal
unless defined $param[0] and substr($param[0], 0, 1) eq "-" 0 2 2
Condition33%1/3
defined $param[0] and substr($param[0], 0, 1) eq "-"
!ll&&!rl&&r
002
MC/DC0%0/2
defined $param[0] and substr($param[0], 0, 1) eq "-"
defined $param[0] substr($param[0], 0, 1) eq "-"
Truth table33%1/3
A and B
A= defined $param[0]B= substr($param[0], 0, 1) eq "-"
ABresult
0X0
100
111
58 }
59  
60 # map parameters into positional indices
61 2 my ($i,%pos);
62 2 $i = 0;
63 2 foreach (@$order) {
64 13 ▶ foreach (ref($_) eq 'ARRAY' ? @$_ : $_) { $pos{$_} = $i; }
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 13 13
65 13 $i++;
66 }
67  
68 2 my (@result); #leave out %leftover.
69 2 $#result = $#$order; #preextend
70 2 ▶ while (@param) {
Branch: 1 branch
BranchTrueFalseTotal
if (@param) 5 2 7
71 5 my $key = uc(shift(@param)); #uc(shift(@param));
72 5 $key =~ s/^\-//;
73 5 ▶ $result[$pos{$key}] = shift(@param) if (exists $pos{$key});
Branch: 1 branch
BranchTrueFalseTotal
if exists $pos{$key} 5 0 5
74 #} else {
75 # $leftover{$key} = shift(@param);
76 #}
77 }
78  
79 #push (@result,$self->make_attributes(\%leftover)) if %leftover;
80 2 return @result;
81 }
82  
83 6 1;
84 __DATA__
« blib/lib/LibWeb/File.pm ↑ Summary blib/lib/LibWeb/Time.pm »