Babble/Plugin/PackageVersion.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 97.0% 33 / 34 CC 2 SCAR 2.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Babble/Plugin/SKT.pm ↑ Summary Babble/SymbolGenerator.pm »
1 package Babble::Plugin::PackageVersion;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶sub transform_to_plain {
Subroutine transform_to_plain: called CC=1 SCAR=0.0
Pod undocumented
7 9 my ($self, $top) = @_;
8 $top->each_match_within(PackageDeclaration => [
9 [ name => q{
10 package
11 (?>(?&PerlNWS)) (?>(?&PerlQualifiedIdentifier))
12 }],
13 [ ws => q{
14 (?>(?&PerlNWS))
15 }],
16 [ version => q{
17 (?&PerlVersionNumber)
18 }],
19 q{
20 (?>(?&PerlOWSOrEND))
21 },
22 [ rest => q[
23 (?> ; | (?&PerlBlock) | (?= \} | \z ))
24 ]],
25 7 ▶ ] => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
26 7 my ($m) = @_;
27 7 my $gr = $m->grammar_regexp;
28  
29 my ($name, $ws, $version, $rest) =
30 7 @{$m->submatches}{ qw(name ws version rest) };
31  
32 7 $ws->replace_text('');
33  
34 7 my $version_info = do {
35 7 local $Data::Dumper::Terse = 1;
36 7 local $Data::Dumper::Indent = 0;
37 7 Dumper($version->text);
38 };
39 # not using line with $VERSION to avoid inaccurate VERSION detection
40 7 my $version_statement = qq{our \044VERSION = }.$version_info.';';
41 7 $version->replace_text('');
42  
43 7 ▶ if( $rest->text =~ /\A\{/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest->text =~ /\A\{/) { } 2 5 7
44 2 ▶ $rest->transform_text(sub { s/\A \{ (?&PerlOWS) $gr/{\n${version_statement}\n/x });
Subroutine __ANON__: called CC=1 SCAR=0.0
45 } else {
46 5 ▶ $rest->transform_text(sub { s/\A ;? /;\n${version_statement}\n/x });
Subroutine __ANON__: called CC=1 SCAR=0.0
47 }
48 9 });
49 }
50  
51 1 1;
52 __END__
« Babble/Plugin/SKT.pm ↑ Summary Babble/SymbolGenerator.pm »