Reply/Plugin/Hints.pm

filter: Statementstmt 45.9% 17 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 66.6% 2 / 3 totaltotal 48.9% 23 / 47 CC 1 SCAR 3.6
CC
1
Cov
46%
new
2.0
mangle_line
2.0
compile
2.0
CRAP 1.4
« Reply/Plugin/Interrupt.pm ↑ Summary
1 package Reply::Plugin::Hints;
2 1 our $AUTHORITY = 'cpan:DOY';
3 1 $Reply::Plugin::Hints::VERSION = '0.42';
4 1 my $default_hints;
5 my $default_hinthash;
6 1 my $default_warning_bits;
7 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 $default_hints = $^H;
9 1 $default_hinthash = \%^H;
10 1 $default_warning_bits = ${^WARNING_BITS};
11 }
12  
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 # ABSTRACT: persists lexical hints across input lines
16  
17 1 ▶use base 'Reply::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
21 0 my $class = shift;
22  
23 0 my $self = $class->SUPER::new(@_);
24 0 $self->{hints} = $default_hints;
25 0 $self->{hinthash} = $default_hinthash;
26 0 $self->{warning_bits} = $default_warning_bits;
27  
28 0 return $self;
29 }
30  
31 0 ▶sub mangle_line {
Subroutine mangle_line: not called CC=1 SCAR=6.9
Pod documented
32 0 my $self = shift;
33 0 my ($line) = @_;
34  
35 0 my $package = __PACKAGE__;
36 0 return <<LINE;
37 BEGIN {
38 \$^H = \$${package}::hints;
39 \%^H = \%\$${package}::hinthash;
40 \${^WARNING_BITS} = \$${package}::warning_bits;
41 }
42 $line
43 ;
44 BEGIN {
45 \$${package}::hints = \$^H;
46 \$${package}::hinthash = \\\%^H;
47 \$${package}::warning_bits = \${^WARNING_BITS};
48 }
49 LINE
50 }
51  
52 0 ▶sub compile {
Subroutine compile: not called CC=1 SCAR=6.9
Pod documented
53 0 my $self = shift;
54 0 my ($next, $line, %args) = @_;
55  
56 # XXX it'd be nice to avoid using globals here, but we can't use
57 # eval_closure's environment parameter since we need to access the
58 # information in a BEGIN block
59 0 our $hints = $self->{hints};
60 0 our $hinthash = $self->{hinthash};
61 0 our $warning_bits = $self->{warning_bits};
62  
63 0 my @result = $next->($line, %args);
64  
65 0 $self->{hints} = $hints;
66 0 $self->{hinthash} = $hinthash;
67 0 $self->{warning_bits} = $warning_bits;
68  
69 0 return @result;
70 }
71  
72 1 1;
73  
74 __END__
« Reply/Plugin/Interrupt.pm ↑ Summary