Reply/Plugin/ResultCache.pm

filter: Statementstmt 34.2% 12 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 75.0% 3 / 4 totaltotal 32.7% 18 / 55 CC 5 SCAR 17.8
CC
5
Cov
28%
execute
12.0
new
6.0
mangle_result
6.0
CRAP 5.9
« Reply/Plugin/Colors.pm ↑ Summary Reply/Plugin/Timer.pm »
1 package Reply::Plugin::ResultCache;
2 1 our $AUTHORITY = 'cpan:DOY';
3 1 $Reply::Plugin::ResultCache::VERSION = '0.42';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: retain previous results to be able to refer to them later
7  
8 1 ▶use base 'Reply::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
12 0 my $class = shift;
13 0 my %opts = @_;
14  
15 0 my $self = $class->SUPER::new(@_);
16 0 $self->{results} = [];
17 0 ▶ $self->{result_name} = $opts{variable} || 'res';
Condition0%0/2
$opts{'variable'} || 'res'
l!l
00
MC/DC0%0/1
$opts{'variable'} || 'res'
$opts{'variable'}
Truth table0%0/2
A
A= $opts{'variable'}
Aresult
11
00
18  
19 0 return $self;
20 }
21  
22 0 ▶sub execute {
Subroutine execute: not called CC=3 SCAR=24.8
Pod documented
23 0 my $self = shift;
24 0 my ($next, @args) = @_;
25  
26 0 my @res = $next->(@args);
27 0 ▶ if (@res == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@res == 1) { } 0 0 0
elsif (@res > 1) { } 0 0 0
28 0 push @{ $self->{results} }, $res[0];
29 }
30 elsif (@res > 1) {
31 0 push @{ $self->{results} }, \@res;
32 }
33  
34 0 return @res;
35 }
36  
37 0 ▶sub mangle_result {
Subroutine mangle_result: not called CC=2 SCAR=17.9
Pod documented
38 0 my $self = shift;
39 0 my ($result) = @_;
40  
41 0 ▶ return unless defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 0 0 0
42 0 return '$' . $self->{result_name} . '[' . $#{ $self->{results} } . '] = '
43 . $result;
44 }
45  
46 0 ▶sub lexical_environment {
Subroutine lexical_environment: not called CC=1 SCAR=6.9
Pod documented
47 0 my $self = shift;
48 0 return { "\@$self->{result_name}" => [ @{ $self->{results} } ] };
49 }
50  
51 1 1;
52  
53 __END__
« Reply/Plugin/Colors.pm ↑ Summary Reply/Plugin/Timer.pm »