lib/TUI/Menus/MenuItem.pm

filter: Statementstmt 54.5% 42 / 77 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 52.6% 10 / 19 Podpod 85.7% 6 / 7 totaltotal 50.4% 58 / 115 CC 7 SCAR 17.8
CC
7
Cov
47%
DEMOLISH
20.0
BUILD
12.0
from
6.0
CRAP 5.9
« lib/TUI/Drivers/Colors.pm ↑ Summary lib/TUI/Gadgets/FileWindow.pm »
1 package TUI::Menus::MenuItem;
2 # ABSTRACT: Class linking text, hot key, command, and help for use within a menu
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 TMenuItem
15 newLine
16 new_TMenuItem
17 );
18
19 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 44 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 44 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 44 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
23 Maybe
24 is_Object
25 :types
26 44 );
27
28 44 ▶use TUI::Views::Const qw( hcNoContext );
Subroutine BEGIN: called CC=1 SCAR=0.0
29 44 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
30
31 sub TMenuItem() { __PACKAGE__ }
32 0 ▶sub new_TMenuItem { __PACKAGE__->from(@_) }
Subroutine new_TMenuItem: not called CC=1 SCAR=6.9
Pod documented
33
34 # public attributes
35 44 has next => ( is => 'rw' );
36 0 ▶has name => ( is => 'rw', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
37 44 has command => ( is => 'rw', default => 0 );
38 44 has disabled => ( is => 'rw', default => false );
39 0 ▶has keyCode => ( is => 'rw', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
40 44 has helpCtx => ( is => 'rw', default => hcNoContext );
41 44 has param => ( is => 'rw', default => '' );
42 44 has subMenu => ( is => 'rw' );
43
44 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
45 0 state $sig = signature(
46 method => 1,
47 named => [
48 name => Str, { alias => 'aName' },
49 keyCode => PositiveOrZeroInt, { alias => 'aKeyCode' },
50 command => PositiveOrZeroInt, { alias => 'aCommand', optional => 1 },
51 subMenu => Maybe[Object], { alias => 'aSubMenu', optional => 1 },
52 helpCtx => PositiveOrZeroInt, { alias => 'aHelpCtx', optional => 1 },
53 param => Str, { alias => 'p', optional => 1 },
54 next => Maybe[Object], { alias => 'aNext', optional => 1 },
55 ],
56 caller_level => +1,
57 );
58 0 my ( $class, $args ) = $sig->( @_ );
59 0 return { %$args };
60 }
61
62 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
63 0 my ( $self, $args ) = @_;
64 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
65 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
66 0 $self->{disabled} = !TView->commandEnabled( $self->{command} );
67 0 return;
68 }
69
70 0 ▶sub from { # $obj ($aName, |$aCommand, $aKeyCode, |$aSubMenu, $aHelpCtx, |$p, |$aNext)
Subroutine from: not called CC=2 SCAR=17.9
Pod undocumented
71 0 ▶ if ( looks_like_number $_[3] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&looks_like_number($_[3])) { } 0 0 0
72 0 state $sig = signature(
73 method => 1,
74 pos => [
75 Str,
76 PositiveOrZeroInt,
77 PositiveOrZeroInt,
78 PositiveOrZeroInt, { default => hcNoContext },
79 Str, { default => '' },
80 Maybe[Object], { default => undef },
81 ],
82 );
83 0 my ( $class, @args ) = $sig->( @_ );
84 0 return $class->new( name => $args[0], command => $args[1],
85 keyCode => $args[2], helpCtx => $args[3], param => $args[4],
86 next => $args[6] );
87 }
88 else {
89 0 state $sig = signature(
90 method => 1,
91 pos => [
92 Str,
93 PositiveOrZeroInt,
94 Maybe[Object],
95 PositiveOrZeroInt, { default => hcNoContext },
96 Maybe[Object], { default => undef },
97 ],
98 );
99 0 my ( $class, @args ) = $sig->( @_ );
100 0 return $class->new( name => $args[0], keyCode => $args[1],
101 subMenu => $args[2], helpCtx => $args[3], next => $args[4] );
102 }
103 }
104
105 0 ▶sub DEMOLISH { # void ($in_global_destruction)
Subroutine DEMOLISH: not called CC=4 SCAR=30.0
Pod documented
106 0 my ( $self, $in_global_destruction ) = @_;
107 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
108 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
109 0 undef $self->{name};
110 0 ▶ if ( $self->{command} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'command'} == 0) { } 0 0 0
111 0 undef $self->{subMenu};
112 }
113 else {
114 0 undef $self->{param};
115 }
116 0 return;
117 }
118
119 0 ▶sub append { # void ($aNext)
Subroutine append: not called CC=1 SCAR=6.9
Pod documented
120 0 state $sig = signature(
121 method => Object,
122 pos => [Object],
123 );
124 0 my ( $self, $aNext ) = $sig->( @_ );
125 0 $self->{next} = $aNext;
126 0 return;
127 }
128
129 0 ▶sub newLine () { # $menuItem ()
Subroutine newLine: not called CC=1 SCAR=6.9
Pod documented
130 0 return TMenuItem->new(
131 name => '',
132 command => 0,
133 keyCode => 0,
134 helpCtx => hcNoContext,
135 param => '',
136 next => undef,
137 );
138 }
139
140 44 1
141
142 __END__
« lib/TUI/Drivers/Colors.pm ↑ Summary lib/TUI/Gadgets/FileWindow.pm »