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