File Coverage

blib/lib/Babble/Plugin/Sigify.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Babble::Plugin::Sigify;
2              
3 1     1   67904 use strictures 2;
  1         20  
  1         49  
4 1     1   722 use Moo;
  1         7044  
  1         5  
5              
6             sub transform_to_plain {
7 2     2 0 3144 my ($self, $top) = @_;
8             my $tf = sub {
9 2     2   6 my ($m) = @_;
10 2         45 my $body = $m->submatches->{body}->text;
11 2         10 $body =~ s/^\s+//;
12 2 50       22 if ($body =~ s/^\{\s*my\s*(\([^\)]+\))\s*=\s*\@_\s*;/{/sm) {
13 2         8 my $sig = $1;
14 2         6 $body =~ s/^{\n\n/{\n/;
15 2         47 $m->submatches->{body}->replace_text($sig.' '.$body);
16             }
17 2         14 };
18 2         18 $top->each_match_within('SubroutineDeclaration' => [
19             'sub \b (?&PerlOWS) (?&PerlOldQualifiedIdentifier) (?&PerlOWS)',
20             '(?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+',
21             [ body => '(?&PerlBlock)' ], '(?&PerlOWS)'
22             ] => $tf);
23 2         18 $top->each_match_within('AnonymousSubroutine' => [
24             'sub \b (?&PerlOWS)',
25             '(?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+',
26             [ body => '(?&PerlBlock)' ], '(?&PerlOWS)'
27             ] => $tf);
28             }
29              
30             1;
31             __END__
32              
33             =head1 NAME
34              
35             Babble::Plugin::Sigify - Plugin to convert @_ unpacking to signature syntax
36              
37             =head1 SEE ALSO
38              
39             L<signatures feature|feature/"The 'signatures' feature">
40              
41             =cut