Reply/Plugin/LexicalPersistence.pm

filter: Statementstmt 48.3% 15 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 66.6% 2 / 3 totaltotal 51.2% 21 / 41 CC 2 SCAR 9.2
CC
2
Cov
48%
compile
6.0
new
2.0
lexical_environment
2.0
CRAP 2.5
« Reply/Plugin/Packages.pm ↑ Summary Reply/Plugin/LoadClass.pm »
1 package Reply::Plugin::LexicalPersistence;
2 1 our $AUTHORITY = 'cpan:DOY';
3 1 $Reply::Plugin::LexicalPersistence::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: persists lexical variables between lines
7  
8 1 ▶use base 'Reply::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use PadWalker 'peek_sub', 'closed_over';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
14 0 my $class = shift;
15 0 my %opts = @_;
16  
17 0 my $self = $class->SUPER::new(@_);
18 0 $self->{env} = {};
19  
20 0 return $self;
21 }
22  
23 0 ▶sub compile {
Subroutine compile: not called CC=2 SCAR=17.9
Pod documented
24 0 my $self = shift;
25 0 my ($next, $line, %args) = @_;
26  
27 0 my ($code) = $next->($line, %args);
28  
29 0 my $new_env = peek_sub($code);
30 0 delete $new_env->{$_} for keys %{ closed_over($code) };
31  
32 $self->{env} = {
33 0 %{ $self->{env} },
34 %$new_env,
35 };
36  
37 0 return $code;
38 }
39  
40 0 ▶sub lexical_environment {
Subroutine lexical_environment: not called CC=1 SCAR=6.9
Pod documented
41 0 my $self = shift;
42  
43 0 return $self->{env};
44 }
45  
46 1 1;
47  
48 __END__
« Reply/Plugin/Packages.pm ↑ Summary Reply/Plugin/LoadClass.pm »