blib/lib/CGI/Widget/Path.pm

filter: Statementstmt 35.6% 26 / 73 Branchbran 26.6% 8 / 30 Conditioncond 16.0% 4 / 25 MC/DCmcdc 7.1% 1 / 14 Subroutinesub 57.1% 4 / 7 Podpod 100% 5 / 5 totaltotal 31.1% 48 / 154 CC 27 SCAR 45.6
CC
27
Cov
30%
asHTML
210.0
new
14.8
deleteElem
12.0
CRAP 95.4
↑ Summary
1 package CGI::Widget::Path;
2  
3 3 require 5.005;
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 $VERSION = '0.01';
8  
9 2 ▶sub new {
Subroutine new: called CC=11 SCAR=26.9
Pod documented
10 2 my $proto = shift;
11 2 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
12 2 ▶ my $self = ($#_ == 0) ? shift : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
$#_ == 0 ? : 0 2 2
13 2 ▶ $self->{'separator'} = '>' unless defined $self->{'separator'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"separator"} 0 2 2
14 2 ▶ $self->{'link_last'} = 0 unless ( defined $self->{'link_last'} and $self->{'link_last'} =~ /^(0|1)$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"link_last"} and $self->{"link_last"} =~ /^(0|1)$/ 1 1 2
Condition66%2/3
defined $self->{"link_last"} and $self->{"link_last"} =~ /^(0|1)$/
!ll&&!rl&&r
101
MC/DC50%1/2
defined $self->{"link_last"} and $self->{"link_last"} =~ /^(0|1)$/
defined $self->{"link_last"} $self->{"link_last"} =~ /^(0|1)$/
Truth table66%2/3
A and B
A= defined $self->{"link_last"}B= $self->{"link_last"} =~ /^(0|1)$/
ABresult
0X0
100
111
15 2 ▶ $self->{'link'} = 1 unless ( defined $self->{'link'} and $self->{'link'} =~ /^(0|1)$/ );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"link"} and $self->{"link"} =~ /^(0|1)$/ 2 0 2
Condition33%1/3
defined $self->{"link"} and $self->{"link"} =~ /^(0|1)$/
!ll&&!rl&&r
200
MC/DC0%0/2
defined $self->{"link"} and $self->{"link"} =~ /^(0|1)$/
defined $self->{"link"} $self->{"link"} =~ /^(0|1)$/
Truth table33%1/3
A and B
A= defined $self->{"link"}B= $self->{"link"} =~ /^(0|1)$/
ABresult
0X0
100
111
16 2 bless $self,$class;
17 2 ▶ if ( $self->{'path'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"path"}) 1 1 2
18 1 eval { require File::Spec};
19 1 foreach ( File::Spec->splitdir($self->{'path'}) ) {
20 1 $self->addElem( elems => [
21 { name => $_, wrap => [ { tag => 'a', attr => { 'href' => "$_/" } } ], append => 1 },
22 ] );
23 }
24 0 ▶ $self->{elems}->[0]->{'name'} ||= 'root';
Condition0%0/2
$self->{"elems"}[0]{"name"} ||= "root"
l!l
00
MC/DC0%0/1
$self->{"elems"}[0]{"name"} ||= "root"
$self->{"elems"}[0]{"name"}
Truth table0%0/2
A
A= $self->{"elems"}[0]{"name"}
Aresult
11
00
25 }
26 1 return $self;
27 }
28  
29 0 ▶sub asHTML {
Subroutine asHTML: not called CC=14 SCAR=53.5
Pod documented
30 0 my ($self,%args) = @_;
31 0 my $str;
32 0 ▶ my $tree_path = "$self->{'base_url'}" if $self->{'base_url'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"base_url"} 0 0 0
33  
34 0 ▶ for (my $i = 0; $i <= $#{@{$self->{'elems'}}}; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{@{$$self{"elems"};};}) 0 0 0
35 #next if ( ! exists ${@{$self->{'elems'}}}[$i]{'name'} or ${@{$self->{'elems'}}}[$i]{'name'} eq '' ) ;
36 0 ▶ next unless ( exists ${@{$self->{'elems'}}}[$i]{'name'} and ${@{$self->{'elems'}}}[$i]{'name'} ne '' ) ;
Branch: 1 branch
BranchTrueFalseTotal
unless exists do { @{$$self{"elems"};} }->[$i]{"name"} and do { @{$$self{"elems"};} }->[$i]{"name"} ne "" 0 0 0
Condition0%0/3
exists do { @{$$self{"elems"};} }->[$i]{"name"} and do { @{$$self{"elems"};} }->[$i]{"name"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists do { @{$$self{"elems"};} }->[$i]{"name"} and do { @{$$self{"elems"};} }->[$i]{"name"} ne ""
exists do { @{$$self{"elems"};} }->[$i]{"name"} do { @{$$self{"elems"};} }->[$i]{"name"} ne ""
Truth table0%0/3
A and B
A= exists do { @{$$self{"elems"};} }->[$i]{"name"}B= do { @{$$self{"elems"};} }->[$i]{"name"} ne ""
ABresult
0X0
100
111
37 0 my $element = ${@{$self->{'elems'}}}[$i]{'name'};
38 0 ▶ $str .= $self->{'separator'} if $i > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i > 0 0 0 0
39 0 foreach my $wrap( @{${@{$self->{'elems'}}}[$i]{'wrap'}} ) {
40 0 ▶ unless ( $wrap->{'tag'} =~ /^a$/i and ( ($i == $#{@{$self->{'elems'}}} and ! $self->{'link_last'}) || ! $self->{'link'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wrap->{"tag"} =~ /^a$/i and $i == $#{@{$$self{"elems"};};} && !$self->{"link_last"} || !$self->{"link"}) 0 0 0
Condition0%0/9
$wrap->{"tag"} =~ /^a$/i and $i == $#{@{$$self{"elems"};};} && !$self->{"link_last"} || !$self->{"link"}
!ll&&!rl&&r
000
$i == $#{@{$$self{"elems"};};} and not $self->{"link_last"} or not $self->{"link"}
l!l&&r!l&&!r
000
$i == $#{@{$$self{"elems"};};} and not $self->{"link_last"}
!ll&&!rl&&r
000
MC/DC0%0/4
$wrap->{"tag"} =~ /^a$/i and $i == $#{@{$$self{"elems"};};} && !$self->{"link_last"} || !$self->{"link"}
$wrap->{"tag"} =~ /^a$/i $i == $#{@{$$self{"elems"};};} not $self->{"link_last"} not $self->{"link"}
Truth table0%0/6
A and B and not(C) or not(D)
A= $wrap->{"tag"} =~ /^a$/iB= $i == $#{@{$$self{"elems"};};}C= not $self->{"link_last"}D= not $self->{"link"}
ABCDresult
0XXX0
10X00
11000
111X1
10X11
11011
41 0 ▶ $element = '<' . $wrap->{'tag'} . ($wrap->{'attr'} ? ' ' . join ' ', map {"$_=\"" . ($_ =~ /^href$/i ? (${@{$self->{'elems'}}}[$i]{'append'} ? ($tree_path .= $wrap->{'attr'}{$_}) : "$self->{'base_url'}$wrap->{'attr'}{$_}") : "$wrap->{'attr'}{$_}") . '"'} keys %{$wrap->{'attr'}} : '' ) . '>' . $element . '</' . $wrap->{'tag'} . '>';
Branch: 3 branches
BranchTrueFalseTotal
$wrap->{'attr'} ? : 0 0 0
$_ =~ /^href$/i ? : 0 0 0
do { @{$$self{'elems'};} }->[$i]{'append'} ? : 0 0 0
42 }
43 }
44 0 $str .= $element;
45 }
46 0 $self->{'out'} = $str;
47 0 return $self->{'out'};
48 }
49  
50 2 ▶sub addElem {
Subroutine addElem: called CC=2 SCAR=9.7
Pod documented
51 2 my ($self,%args) = @_;
52 2 ▶ $args{'position'} = ($#{@{$self->{'elems'}}} + 1) if ! defined $args{'position'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"position"} 2 0 2
53 0 splice(@{$self->{'elems'}}, $args{'position'}, 0, @{$args{'elems'}});
54 0 return scalar @{$self->{'elems'}};
55 }
56  
57 0 ▶sub deleteElem {
Subroutine deleteElem: not called CC=3 SCAR=24.8
Pod documented
58 0 my ($self,%args) = @_;
59 0 ▶ $args{'position'} = $#{@{$self->{'elems'}}} if ! defined $args{'position'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"position"} 0 0 0
60 0 ▶ $args{'lenght'} ||= 1;
Condition0%0/2
$args{"lenght"} ||= 1
l!l
00
MC/DC0%0/1
$args{"lenght"} ||= 1
$args{"lenght"}
Truth table0%0/2
A
A= $args{"lenght"}
Aresult
11
00
61 0 splice(@{$self->{'elems'}}, $args{'position'}, $args{'lenght'});
62 0 return scalar @{$self->{'elems'}};
63 }
64  
65 0 ▶sub errstr {
Subroutine errstr: not called CC=1 SCAR=6.9
Pod documented
66 0 my $self = shift;
67 0 $self->{'errstr'};
68 }
69  
70 3 1;
71  
72 __END__
↑ Summary