| 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
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | my $self = ($#_ == 0) ? shift : { @_ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | $self->{'separator'} = '>' unless defined $self->{'separator'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | $self->{'link_last'} = 0 unless ( defined $self->{'link_last'} and $self->{'link_last'} =~ /^(0|1)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"link_last"} and $self->{"link_last"} =~ /^(0|1)$/
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)$/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | $self->{'link'} = 1 unless ( defined $self->{'link'} and $self->{'link'} =~ /^(0|1)$/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"link"} and $self->{"link"} =~ /^(0|1)$/
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)$/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | bless $self,$class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | if ( $self->{'path'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"
MC/DC0%0/1
$self->{"elems"}[0]{"name"} ||= "root"
$self->{"elems"}[0]{"name"}
Truth table0%0/2
A
A= $self->{"elems"}[0]{"name"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | for (my $i = 0; $i <= $#{@{$self->{'elems'}}}; $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
exists do {
@{$$self{"elems"};}
}->[$i]{"name"} and do {
@{$$self{"elems"};}
}->[$i]{"name"} ne ""
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 ""
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $element = ${@{$self->{'elems'}}}[$i]{'name'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $str .= $self->{'separator'} if $i > 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/9
$wrap->{"tag"} =~ /^a$/i and $i == $#{@{$$self{"elems"};};} && !$self->{"link_last"} || !$self->{"link"}
$i == $#{@{$$self{"elems"};};} and not $self->{"link_last"} or not $self->{"link"}
$i == $#{@{$$self{"elems"};};} and not $self->{"link_last"}
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"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $args{'lenght'} ||= 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"lenght"} ||= 1
MC/DC0%0/1
$args{"lenght"} ||= 1
$args{"lenght"}
Truth table0%0/2
A
A= $args{"lenght"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||