lib/CodeGen/Protection.pm

filter: Statementstmt 100% 38 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 100% 51 / 51 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Test/CodeGen/Protection.pm ↑ Summary lib/CodeGen/Protection/Format/HTML.pm »
1 package CodeGen::Protection;
2  
3 # ABSTRACT: Safely rewrite parts of generated code
4  
5 4 ▶use v5.08.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use CodeGen::Protection::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
12 compile_named
13 NonEmptyStr
14 Bool
15 Optional
16 4 );
17  
18 4 our $VERSION = '0.06';
19 4 our @EXPORT_OK = qw(
20 create_protected_code
21 rewrite_code
22 );
23 4 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
24  
25 {
26 4 my $check = compile_named(
27 type => NonEmptyStr,
28 protected_code => NonEmptyStr,
29 tidy => Optional [Bool],
30 name => Optional [NonEmptyStr],
31 overwrite => Optional [Bool],
32 );
33  
34 5 ▶ sub create_protected_code {
Subroutine create_protected_code: called CC=1 SCAR=0.0
Pod documented
35 5 return _rewritten( $check->(@_) );
36 }
37 }
38  
39 {
40 4 my $check = compile_named(
41 type => NonEmptyStr,
42 protected_code => NonEmptyStr,
43 existing_code => NonEmptyStr,
44 tidy => Optional [Bool],
45 name => Optional [NonEmptyStr],
46 overwrite => Optional [Bool],
47 );
48  
49 13 ▶ sub rewrite_code {
Subroutine rewrite_code: called CC=1 SCAR=0.0
Pod documented
50 13 return _rewritten( $check->(@_) );
51 }
52 }
53  
54 4 ▶sub _rewritten {
Subroutine _rewritten: called CC=1 SCAR=0.0
55 18 my $arg_for = shift;
56 18 my $type = delete $arg_for->{type};
57 18 my $class = _use_module($type);
58 18 return $class->new($arg_for)->rewritten;
59 }
60  
61 18 ▶sub _use_module {
Subroutine _use_module: called CC=1 SCAR=0.0
62 18 my $format = shift;
63 18 my $class = "CodeGen::Protection::Format::$format";
64 18 use_module($class);
65 18 return $class;
66 }
67  
68 4 1;
69  
70 __END__
« blib/lib/Test/CodeGen/Protection.pm ↑ Summary lib/CodeGen/Protection/Format/HTML.pm »