NavMenu/Iterator/GetCurrentlyActive.pm

filter: Statementstmt 100% 52 / 52 Branchbran 100% 8 / 8 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 5 / 5 Subroutinesub 100% 12 / 12 Podpod 100% 7 / 7 totaltotal 100% 93 / 93 CC 8 SCAR 7.2
CC
8
Cov
100%
item_matches
3.0
node_start
3.0
node_end
3.0
CRAP 2.1
« NavMenu/Tree/Iterator.pm ↑ Summary NavMenu/Iterator/Html.pm »
1 package HTML::Widgets::NavMenu::Iterator::GetCurrentlyActive;
2 15 $HTML::Widgets::NavMenu::Iterator::GetCurrentlyActive::VERSION = '1.1000';
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use parent 'HTML::Widgets::NavMenu::Iterator::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 __PACKAGE__->mk_acc_ref(
9 [
10 qw(
11 _item_found
12 _leading_path_coords
13 _ret_coords
14 _temp_coords
15 _tree
16 )
17 ]
18 );
19  
20 sub _init
21 52 ▶{
Subroutine _init: called CC=1 SCAR=0.0
22 52 my $self = shift;
23 52 my $args = shift;
24  
25 52 $self->SUPER::_init($args);
26  
27 52 $self->_tree( $args->{'tree'} );
28  
29 52 $self->_item_found(0);
30  
31 52 return 0;
32 }
33  
34 sub get_initial_node
35 52 ▶{
Subroutine get_initial_node: called CC=1 SCAR=0.0
Pod documented
36 52 my $self = shift;
37  
38 52 return $self->_tree;
39 }
40  
41 sub item_matches
42 270 ▶{
Subroutine item_matches: called CC=3 SCAR=11.0
Pod documented
43 270 my $self = shift;
44 270 my $item = $self->top();
45 270 my $url = $item->_node()->url();
46 270 my $nav_menu = $self->nav_menu();
47 270 ▶ return ( ( $item->_accum_state()->{'host'} eq $nav_menu->current_host() )
Condition100%6/6
$item->_accum_state->{'host'} eq $nav_menu->current_host && (defined $url && $url eq $nav_menu->path_info)
!ll&&!rl&&r
3021327
defined $url and $url eq $nav_menu->path_info
!ll&&!rl&&r
5016327
MC/DC100%3/3
$item->_accum_state->{'host'} eq $nav_menu->current_host && (defined $url && $url eq $nav_menu->path_info)
$item->_accum_state->{'host'} eq $nav_menu->current_host defined $url $url eq $nav_menu->path_info
Truth table100%4/4
A && B and C
A= $item->_accum_state->{'host'} eq $nav_menu->current_hostB= defined $urlC= $url eq $nav_menu->path_info
ABCresult
0XX0
10X0
1100
1111
48 && ( defined($url) && ( $url eq $nav_menu->path_info() ) ) );
49 }
50  
51 sub does_item_expand
52 243 ▶{
Subroutine does_item_expand: called CC=1 SCAR=0.0
Pod documented
53 243 my $self = shift;
54 243 my $item = $self->top();
55 243 return $item->_node()->capture_expanded();
56 }
57  
58 sub node_start
59 270 ▶{
Subroutine node_start: called CC=3 SCAR=11.0
Pod documented
60 270 my $self = shift;
61  
62 270 ▶ if ( $self->item_matches() )
Branch: 2 branches
BranchTrueFalseTotal
if ($self->item_matches) { } 27 243 270
elsif ($self->does_item_expand) { } 23 220 243
63 {
64 27 my @coords = @{ $self->get_coords() };
65 27 $self->_ret_coords( [@coords] );
66 27 $self->_temp_coords( [ @coords, (-1) ] );
67 27 $self->top()->_node()->mark_as_current();
68 27 $self->_item_found(1);
69 }
70 elsif ( $self->does_item_expand() )
71 {
72 23 my @coords = @{ $self->get_coords() };
73 23 $self->_leading_path_coords( [@coords] );
74 }
75 }
76  
77 sub node_end
78 270 ▶{
Subroutine node_end: called CC=3 SCAR=11.0
Pod documented
79 270 my $self = shift;
80 270 ▶ if ( $self->_item_found() )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_item_found) 61 209 270
81 {
82 # Skip the first node, because the coords refer
83 # to the nodes below it.
84 61 my $idx = pop( @{ $self->_temp_coords() } );
85 61 ▶ if ( $idx >= 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($idx >= 0) 34 27 61
86 {
87 34 my $node = $self->top()->_node();
88 34 $node->update_based_on_sub( $node->get_nth_sub($idx) );
89 }
90 }
91 }
92  
93 sub node_should_recurse
94 488 ▶{
Subroutine node_should_recurse: called CC=1 SCAR=0.0
Pod documented
95 488 my $self = shift;
96 488 return ( !$self->_item_found() );
97 }
98  
99 sub get_final_coords
100 52 ▶{
Subroutine get_final_coords: called CC=1 SCAR=0.0
Pod documented
101 52 my $self = shift;
102  
103 52 return $self->_ret_coords();
104 }
105  
106 sub _get_leading_path_coords
107 52 ▶{
Subroutine _get_leading_path_coords: called CC=2 SCAR=6.9
108 52 my $self = shift;
109  
110 52 ▶ return ( $self->_ret_coords() || $self->_leading_path_coords() );
Condition100%3/3
$self->_ret_coords || $self->_leading_path_coords
l!l&&r!l&&!r
27916
MC/DC100%2/2
$self->_ret_coords || $self->_leading_path_coords
$self->_ret_coords $self->_leading_path_coords
Truth table100%3/3
A || B
A= $self->_ret_coordsB= $self->_leading_path_coords
ABresult
1X1
011
000
111 }
112  
113 15 1;
114  
115 __END__
« NavMenu/Tree/Iterator.pm ↑ Summary NavMenu/Iterator/Html.pm »