Reply/Plugin/Packages.pm

filter: Statementstmt 42.8% 12 / 28 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 75.0% 3 / 4 totaltotal 42.8% 18 / 42 CC 2 SCAR 9.7
CC
2
Cov
40%
new
6.0
mangle_line
2.0
compile
2.0
CRAP 2.6
« Reply/Plugin.pm ↑ Summary Reply/Plugin/LexicalPersistence.pm »
1 package Reply::Plugin::Packages;
2 1 our $AUTHORITY = 'cpan:DOY';
3 1 $Reply::Plugin::Packages::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: persist the current package between lines
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->{package} = $opts{default_package} || 'main';
Condition0%0/2
$opts{'default_package'} || 'main'
l!l
00
MC/DC0%0/1
$opts{'default_package'} || 'main'
$opts{'default_package'}
Truth table0%0/2
A
A= $opts{'default_package'}
Aresult
11
00
17  
18 0 return $self;
19 }
20  
21 0 ▶sub mangle_line {
Subroutine mangle_line: not called CC=1 SCAR=6.9
Pod documented
22 0 my $self = shift;
23 0 my ($line) = @_;
24  
25 0 my $package = __PACKAGE__;
26 0 return <<LINE;
27 $line
28 ;
29 BEGIN {
30 \$${package}::package = __PACKAGE__;
31 }
32 LINE
33 }
34  
35 0 ▶sub compile {
Subroutine compile: not called CC=1 SCAR=6.9
Pod documented
36 0 my $self = shift;
37 0 my ($next, $line, %args) = @_;
38  
39 0 my @result = $next->($line, %args);
40  
41 # XXX it'd be nice to avoid using globals here, but we can't use
42 # eval_closure's environment parameter since we need to access the
43 # information in a BEGIN block
44 0 $self->{package} = our $package;
45  
46 0 return @result;
47 }
48  
49 0 ▶sub package {
Subroutine package: not called CC=1 SCAR=6.9
Pod documented
50 0 my $self = shift;
51 0 return $self->{package};
52 }
53  
54 1 1;
55  
56 __END__
« Reply/Plugin.pm ↑ Summary Reply/Plugin/LexicalPersistence.pm »