blib/lib/Tapper/Reports/Web/Util.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.7% 39 / 43 CC 6 SCAR 13.2
CC
6
Cov
94%
prepare_top_menu
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.8
« blib/lib/Tapper/Reports/Web/Controller/Tapper/User.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Root.pm »
1 package Tapper::Reports::Web::Util;
2 22 our $AUTHORITY = 'cpan:TAPPER';
3 22 $Tapper::Reports::Web::Util::VERSION = '5.0.17';
4 22 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 22 ▶use Perl6::Junction qw /any/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 sub prepare_top_menu
13 21 ▶{
Subroutine prepare_top_menu: called CC=6 SCAR=18.0
Pod documented
14 21 my ($self, $active) = @_;
15 21 my $top_menu = [
16 { key => 'start', text => 'Start', uri => "/tapper/start/", },
17 { key => 'reports', text => 'Reports', uri => "/tapper/reports", },
18 { key => 'testruns', text => 'Testruns', uri => "/tapper/testruns", },
19 { key => 'testplans', text => 'Testplans', uri => "/tapper/testplan", },
20 { key => 'continuoustestruns', text => 'Continuous Testruns', uri => "/tapper/continuoustestruns",},
21 { key => 'metareports', text => 'Metareports', uri => "/tapper/metareports/", },
22 { key => 'manual', text => 'Manual', uri => "/tapper/manual/", },
23 ];
24  
25 # Some keys may be singular with their actions being named in plural or vice versa. Unify this.
26 21 ▶ if ($active) {
Branch: 1 branch
BranchTrueFalseTotal
if ($active) 18 3 21
27 18 $active = lc($active);
28 18 ▶ (my $active_singular) = ($active =~ m/^(.+)s$/) // '';
Condition50%1/2
$active =~ /^(.+)s$/ // ""
l!l
180
MC/DC0%0/1
$active =~ /^(.+)s$/ // ""
$active =~ /^(.+)s$/
Truth table50%1/2
A
A= $active =~ /^(.+)s$/
Aresult
11
00
29 18 ▶ (my $active_plural) = $active."s" // '';
Condition50%1/2
$active . 's' // ""
l!l
180
MC/DC0%0/1
$active . 's' // ""
$active . 's'
Truth table50%1/2
A
A= $active . 's'
Aresult
11
00
30 18 ▶ foreach (@$top_menu) { $_->{active} = 1 if $_->{key} eq any($active, $active_singular, $active_plural) }
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"key"} eq any($active, $active_singular, $active_plural) 8 118 126
31 }
32 21 return $top_menu;
33 }
34  
35  
36  
37 22 1;
38  
39 __END__
« blib/lib/Tapper/Reports/Web/Controller/Tapper/User.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Root.pm »