Kit/Log.pm

filter: Statementstmt 100% 49 / 49 Branchbran 80.0% 8 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 10 / 10 Podpod 83.3% 5 / 6 totaltotal 96.4% 82 / 85 CC 8 SCAR 9.8
CC
8
Cov
97%
record
5.0
BUILD
3.1
note
2.0
CRAP 2.7
« Kit/Widget.pm ↑ Summary Kit/Test/Screen.pm »
1 package Game::Terminal::Kit::Log;
2  
3 7 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 our $VERSION = '0.02';
10  
11 has keep => (
12 is => 'rw',
13 isa => Int,
14 default => 4
15 7 );
16  
17 has [qw/recent notes/] => (
18 is => 'rw',
19 isa => ArrayRef
20 7 );
21  
22 19 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.4
Pod undocumented
23 19 my ($self) = @_;
24 19 ▶ $self->recent([]) unless $self->recent;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->recent 19 0 19
25 19 ▶ $self->notes([]) unless $self->notes;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->notes 19 0 19
26 19 return $self;
27 }
28  
29 38 ▶sub note {
Subroutine note: called CC=2 SCAR=6.9
Pod documented
30 38 my ($self, @lines) = @_;
31 38 ▶ push @{$self->notes}, grep { defined $_ && length $_ } @lines;
Condition100%3/3
defined $_ && length $_
!ll&&!rl&&r
1138
MC/DC100%2/2
defined $_ && length $_
defined $_ length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
32 38 return $self;
33 }
34  
35 20 ▶sub record {
Subroutine record: called CC=5 SCAR=16.1
Pod documented
36 20 my ($self, @lines) = @_;
37 20 ▶ @lines = grep { defined $_ && length $_ } @lines;
Condition100%3/3
defined $_ && length $_
!ll&&!rl&&r
2219
MC/DC100%2/2
defined $_ && length $_
defined $_ length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
38 20 ▶ return $self unless @lines;
Branch: 1 branch
BranchTrueFalseTotal
unless @lines 2 18 20
39 18 my $recent = $self->recent;
40 18 push @{$recent}, [@lines];
41 18 ▶ my $keep = $self->keep > 0 ? $self->keep : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->keep > 0 ? : 17 1 18
42 18 ▶ shift @{$recent} while @{$recent} > $keep;
Branch: 1 branch
BranchTrueFalseTotal
@{$recent;} > $keep and do { shift @{$recent;} } 9 18 27
43 18 return $self;
44 }
45  
46 112 ▶sub lines {
Subroutine lines: called CC=1 SCAR=0.0
Pod documented
47 112 my ($self) = @_;
48 112 return ((map { @{$_} } @{$self->recent}), @{$self->notes});
49 }
50  
51 27 ▶sub shown {
Subroutine shown: called CC=1 SCAR=0.0
Pod documented
52 27 my ($self) = @_;
53 27 $self->notes([]);
54 27 return $self;
55 }
56  
57 3 ▶sub forget {
Subroutine forget: called CC=1 SCAR=0.0
Pod documented
58 3 my ($self) = @_;
59 3 $self->recent([]);
60 3 $self->notes([]);
61 3 return $self;
62 }
63  
64 7 1;
65  
66 __END__
« Kit/Widget.pm ↑ Summary Kit/Test/Screen.pm »