| 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
| |||||||||||||||||||||
| 25 | 19 | ▶ | $self->notes([]) unless $self->notes; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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 $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||
| 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 $_
MC/DC100%2/2
defined $_ && length $_
defined $_
length $_
Truth table100%3/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||
| 38 | 20 | ▶ | return $self unless @lines; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 18 | my $recent = $self->recent; | |||||||||||||||||||
| 40 | 18 | push @{$recent}, [@lines]; | |||||||||||||||||||
| 41 | 18 | ▶ | my $keep = $self->keep > 0 ? $self->keep : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 18 | ▶ | shift @{$recent} while @{$recent} > $keep; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||