lib/TUI/Outline/Node.pm

filter: Statementstmt 65.2% 45 / 69 Branchbran 20.0% 2 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.8% 11 / 19 Podpod 66.6% 2 / 3 totaltotal 59.4% 60 / 101 CC 8 SCAR 13.6
CC
8
Cov
59%
__ANON__
12.0
new
6.0
from
6.0
CRAP 3.9
« lib/TUI/Views/CommandSet.pm ↑ Summary lib/TUI/Views/Palette.pm »
1 package TUI::Outline::Node;
2 # ABSTRACT: node of an outline tree used by outline viewers
3
4 7 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 7 our $VERSION = '2.000003';
9 7 $VERSION =~ tr/_//d;
10 7 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 7 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 our @EXPORT = qw(
14 TNode
15 new_TNode
16 );
17
18 7 ▶use Devel::StrictMode;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 7 ▶use if STRICT => 'Hash::Util';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 7 ▶use TUI::toolkit qw( :utils true );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 7 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 Maybe
23 is_Object
24 :types
25 7 );
26
27 sub TNode() { __PACKAGE__ }
28 0 ▶sub new_TNode { __PACKAGE__->from(@_) }
Subroutine new_TNode: not called CC=1 SCAR=6.9
Pod documented
29
30 # public attributes
31 7 ▶our %HAS; BEGIN {
Subroutine BEGIN: called CC=1 SCAR=2.6
32 %HAS = (
33 0 ▶ text => sub { '' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 ▶ next => sub { undef },
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 ▶ childList => sub { undef },
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 0 ▶ expanded => sub { true },
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 7 );
38 }
39
40 0 ▶sub new { # \$node (%args)
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
41 0 state $sig = signature(
42 method => 1,
43 named => [
44 text => Str, { alias => 'aText' },
45 childList => Maybe[Object], { alias => 'aChildren', optional => 1 },
46 next => Maybe[Object], { alias => 'aNext', optional => 1 },
47 expanded => Bool, { alias => 'initialState', default => true },
48 ],
49 );
50 0 my ( $class, $self ) = $sig->( @_ );
51 $self->{$_} = $HAS{$_}->()
52 0 for grep { not exists $self->{$_} } keys %HAS;
53 0 bless $self, $class;
54 0 Hash::Util::lock_keys( %$self ) if STRICT;
55 0 return $self;
56 }
57
58 0 ▶sub from { # $node ($aText, |$aChildren|undef, |$aNext|undef, |$initialState)
Subroutine from: not called CC=2 SCAR=17.9
Pod undocumented
59 0 ▶ if (@_ == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 0 0 0
60 0 state $sig = signature(
61 method => 1,
62 pos => [Str],
63 );
64 0 my ( $class, $text ) = $sig->( @_ );
65 0 return $class->new( text => $text );
66 }
67 else {
68 0 state $sig = signature(
69 method => 1,
70 pos => [
71 Str,
72 Maybe[Object],
73 Maybe[Object],
74 Bool, { default => true },
75 ],
76 );
77 0 my ( $class, @args ) = $sig->( @_ );
78 0 return $class->new( text => $args[0], childList => $args[1],
79 next => $args[2], expanded => $args[3] );
80 }
81 }
82
83 7 ▶my $mk_accessors = sub {
Subroutine __ANON__: called CC=4 SCAR=16.5
84 7 my ( $pkg ) = @_;
85 7 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 7 7
86 7 ▶ assert ( defined $pkg );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pkg 0 7 7
87 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
88 7 my %HAS = %{"${pkg}::HAS"};
89 7 for my $field ( keys %HAS ) {
90 28 my $full_name = "${pkg}::$field";
91 0 ▶ *$full_name = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
92 0 ▶ assert ( is_Object $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($_[0]) 0 0 0
93 0 ▶ if ( @_ > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
94 0 $_[0]->{$field} = $_[1];
95 }
96 0 $_[0]->{$field};
97 28 };
98 }
99 7 };
100
101 7 __PACKAGE__->$mk_accessors();
102
103 7 1;
104
105 __END__
« lib/TUI/Views/CommandSet.pm ↑ Summary lib/TUI/Views/Palette.pm »