lib/TUI/Menus/Menu.pm

filter: Statementstmt 85.3% 64 / 75 Branchbran 53.8% 14 / 26 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 93.7% 15 / 16 Podpod 83.3% 5 / 6 totaltotal 78.9% 101 / 128 CC 16 SCAR 13.8
CC
16
Cov
77%
deflt
12.0
from
5.3
BUILD
5.1
CRAP 4.0
« lib/TUI/Views/Util.pm ↑ Summary lib/TUI/Views/CommandSet.pm »
1 package TUI::Menus::Menu;
2 # ABSTRACT: Linked list of TMenuItem records
3
4 44 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 44 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 44 our $VERSION = '2.000002';
9 44 $VERSION =~ tr/_//d;
10 44 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 44 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 44 our @EXPORT = qw(
14 TMenu
15 new_TMenu
16 );
17
18 44 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 44 ▶use Scalar::Util qw( weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 44 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 44 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 Maybe
23 is_Object
24 :types
25 44 );
26
27 sub TMenu() { __PACKAGE__ }
28 2 ▶sub new_TMenu { __PACKAGE__->from(@_) }
Subroutine new_TMenu: called CC=1 SCAR=0.0
Pod documented
29
30 # public attributes
31 44 has items => ( is => 'rw' );
32 44 has deflt => ( is => 'bare' ); # weak_ref => 1
33
34 4 ▶my $lock_value = sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
35 4 ▶ Internals::SvREADONLY( $_[0] => 1 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 4 0 4
36 if exists &Internals::SvREADONLY;
37 44 };
38
39 5 ▶my $unlock_value = sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
40 5 ▶ Internals::SvREADONLY( $_[0] => 0 )
Branch: 1 branch
BranchTrueFalseTotal
if exists &Internals::SvREADONLY 5 0 5
41 if exists &Internals::SvREADONLY;
42 44 };
43
44 4 ▶sub BUILDARGS { # \%args (|%args)
Subroutine BUILDARGS: called CC=1 SCAR=0.0
Pod documented
45 4 state $sig = signature(
46 method => 1,
47 named => [
48 items => Object, { optional => 1, },
49 deflt => Object, { optional => 1, alias => 'default' },
50 ],
51 caller_level => +1,
52 );
53 4 my ( $class, $args ) = $sig->( @_ );
54 4 return { %$args };
55 }
56
57 4 ▶sub BUILD { # void (\%args)
Subroutine BUILD: called CC=5 SCAR=16.3
Pod documented
58 4 my ( $self, $args ) = @_;
59 4 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 4 4
60 4 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 4 4
61 4 ▶ $self->{deflt} //= $self->{items};
Condition66%2/3
$self->{"deflt"} //= $self->{"items"}
l!l&&r!l&&!r
301
MC/DC50%1/2
$self->{"deflt"} //= $self->{"items"}
$self->{"deflt"} $self->{"items"}
Truth table66%2/3
A //= B
A= $self->{"deflt"}B= $self->{"items"}
ABresult
1X1
011
000
62 4 ▶ weaken $self->{deflt} if $self->{deflt};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deflt"} 3 1 4
63 4 &$lock_value( $self->{deflt} ) if STRICT;
64 4 return;
65 }
66
67 2 ▶sub from { # $obj (| $itemList, | $TheDefault)
Subroutine from: called CC=5 SCAR=16.7
Pod undocumented
68 2 state $sig = signature(
69 method => 1,
70 pos => [
71 Object, { optional => 1 },
72 Object, { optional => 1 },
73 ],
74 );
75 2 my ( $class, @args ) = $sig->( @_ );
76 2 SWITCH: for ( scalar @args ) {
77 2 ▶ $_ == 0 and return $class->new();
Branch: 1 branch
BranchTrueFalseTotal
$_ == 0 and return $class->new 0 2 2
78 2 ▶ $_ == 1 and return $class->new( items => $args[0], default => $args[0] );
Branch: 1 branch
BranchTrueFalseTotal
$_ == 1 and return $class->new("items", $args[0], "default", $args[0]) 1 1 2
79 1 ▶ $_ == 2 and return $class->new( items => $args[0], default => $args[1] );
Branch: 1 branch
BranchTrueFalseTotal
$_ == 2 and return $class->new("items", $args[0], "default", $args[1]) 1 0 1
80 }
81 0 return;
82 }
83
84 5 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: called CC=4 SCAR=13.9
Pod documented
85 5 my ( $self, $in_global_destruction ) = @_;
86 5 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 5 5
87 5 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 5 5
88 5 ▶ while ( $self->{items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"items"}) 3 5 8
89 3 my $temp = $self->{items};
90 3 $self->{items} = $self->{items}{next};
91 3 undef $temp;
92 }
93 5 &$unlock_value( $self->{deflt} ) if STRICT;
94 5 return;
95 }
96
97 0 ▶sub deflt { # $view|undef (|$view|undef)
Subroutine deflt: not called CC=3 SCAR=24.8
Pod documented
98 0 state $sig = signature(
99 method => Object,
100 pos => [
101 Maybe[Object], { optional => 1 },
102 ],
103 );
104 0 my ( $self, $view ) = $sig->( @_ );
105 0 ▶ goto SET if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
106 GET: {
107 0 return $self->{deflt};
108 }
109 SET: {
110 0 &$unlock_value( $self->{deflt} ) if STRICT;
111 weaken $self->{deflt}
112 0 ▶ if $self->{deflt} = $view;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deflt"} = $view 0 0 0
113 0 &$lock_value( $self->{deflt} ) if STRICT;
114 0 return;
115 }
116 }
117
118 44 1
119
120 __END__
« lib/TUI/Views/Util.pm ↑ Summary lib/TUI/Views/CommandSet.pm »