NavMenu/Iterator/Base.pm

filter: Statementstmt 96.0% 48 / 50 Branchbran 100% 14 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 100% 4 / 4 totaltotal 96.1% 75 / 78 CC 8 SCAR 12.9
CC
8
Cov
97%
get_new_accum_state
7.0
_init
2.0
_is_root
2.0
CRAP 3.6
« NavMenu.pm ↑ Summary NavMenu/Predicate.pm »
1 package HTML::Widgets::NavMenu::Iterator::Base;
2 21 $HTML::Widgets::NavMenu::Iterator::Base::VERSION = '1.1000';
3 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 21 ▶use parent qw(HTML::Widgets::NavMenu::Tree::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 __PACKAGE__->mk_acc_ref(
9 [
10 qw(
11 _html
12 nav_menu
13 )
14 ]
15 );
16  
17  
18 sub _init
19 354 ▶{
Subroutine _init: called CC=2 SCAR=6.9
20 354 my $self = shift;
21 354 my $args = shift;
22  
23 354 $self->SUPER::_init($args);
24  
25 354 ▶ $self->nav_menu( $args->{'nav_menu'} )
Branch: 1 branch
BranchTrueFalseTotal
$self->nav_menu($args->{"nav_menu"}) or die "nav_menu not specified!" 353 1 354
26 or die "nav_menu not specified!";
27  
28 353 $self->_html( [] );
29  
30 353 return 0;
31 }
32  
33 sub _add_tags
34 673 ▶{
Subroutine _add_tags: called CC=1 SCAR=0.0
35 673 my $self = shift;
36 673 push( @{ $self->_html() }, @_ );
37 }
38  
39 sub _is_root
40 0 ▶{
Subroutine _is_root: not called CC=1 SCAR=6.9
41 0 my $self = shift;
42  
43 0 return ( $self->stack->len() == 1 );
44 }
45  
46  
47 sub get_initial_node
48 385 ▶{
Subroutine get_initial_node: called CC=1 SCAR=0.0
Pod documented
49 385 my $self = shift;
50 385 return $self->nav_menu->_get_traversed_tree();
51 }
52  
53  
54 sub get_node_subs
55 1249 ▶{
Subroutine get_node_subs: called CC=1 SCAR=0.0
Pod documented
56 1249 my ( $self, $args ) = @_;
57  
58 1249 my $node = $args->{'node'};
59  
60 1249 return [ @{ $node->subs() } ];
61 }
62  
63  
64 # TODO : This method is too long - refactor.
65 sub get_new_accum_state
66 1249 ▶{
Subroutine get_new_accum_state: called CC=7 SCAR=19.5
Pod documented
67 1249 my ( $self, $args ) = @_;
68  
69 1249 my $parent_item = $args->{'item'};
70 1249 my $node = $args->{'node'};
71  
72 1249 my $prev_state;
73 1249 ▶ if ( defined($parent_item) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent_item) { } 812 437 1249
74 {
75 812 $prev_state = $parent_item->_accum_state();
76 }
77 else
78 {
79 437 $prev_state = +{};
80 }
81  
82 1249 my $show_always = 0;
83 1249 ▶ if ( exists( $prev_state->{'show_always'} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $prev_state->{"show_always"}) 812 437 1249
84 {
85 812 $show_always = $prev_state->{'show_always'};
86 }
87 1249 ▶ if ( defined( $node->show_always() ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->show_always) 45 1204 1249
88 {
89 45 $show_always = $node->show_always();
90 }
91  
92 1249 my $rec_url_type;
93 1249 ▶ if ( exists( $prev_state->{'rec_url_type'} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $prev_state->{"rec_url_type"}) 812 437 1249
94 {
95 812 $rec_url_type = $prev_state->{'rec_url_type'};
96 }
97 1249 ▶ if ( defined( $node->rec_url_type() ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->rec_url_type) 20 1229 1249
98 {
99 20 $rec_url_type = $node->rec_url_type();
100 }
101 return {
102 1249 ▶ 'host' => ( $node->host() ? $node->host() : $prev_state->{'host'} ),
Branch: 1 branch
BranchTrueFalseTotal
$node->host ? : 454 795 1249
103 'show_always' => $show_always,
104 'rec_url_type' => $rec_url_type,
105 };
106 }
107  
108  
109 sub get_results
110 50 ▶{
Subroutine get_results: called CC=1 SCAR=0.0
Pod documented
111 50 my $self = shift;
112  
113 50 return [ @{ $self->_html() } ];
114 }
115  
116  
117 21 1;
118  
119 __END__
« NavMenu.pm ↑ Summary NavMenu/Predicate.pm »