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   70187 use strictures 2;
  1         17  
  1         42  
4 1     1   722 use Moo;
  1         7013  
  1         4  
5              
6             sub transform_to_plain {
7 2     2 0 2940 my ($self, $top) = @_;
8             my $tf = sub {
9 2     2   5 my ($m) = @_;
10 2         56 my $body = $m->submatches->{body}->text;
11 2         9 $body =~ s/^\s+//;
12 2 50       24 if ($body =~ s/^\{\s*my\s*(\([^\)]+\))\s*=\s*\@_\s*;/{/sm) {
13 2         6 my $sig = $1;
14 2         5 $body =~ s/^{\n\n/{\n/;
15 2         43 $m->submatches->{body}->replace_text($sig.' '.$body);
16             }
17 2         14 };
18 2         17 $top->each_match_within('SubroutineDeclaration' => [
19             'sub \b (?&PerlOWS) (?&PerlOldQualifiedIdentifier) (?&PerlOWS)',
20             '(?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+',
21             [ body => '(?&PerlBlock)' ], '(?&PerlOWS)'
22             ] => $tf);
23 2         21 $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