File Coverage

blib/lib/Babble/Plugin/PackageBlock.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Babble::Plugin::PackageBlock;
2              
3 1     1   70372 use Moo;
  1         7148  
  1         5  
4              
5             sub transform_to_plain {
6 2     2 0 2922 my ($self, $top) = @_;
7             $top->each_match_within(PackageDeclaration => [
8             [ kw => 'package' ],
9             [ meta => q{
10             (?>(?&PerlNWS)) (?>(?&PerlQualifiedIdentifier))
11             (?: (?>(?&PerlNWS)) (?&PerlVersionNumber) )?+
12             }],
13             [ ws => q{
14             (?>(?&PerlOWSOrEND))
15             }],
16             [ block => q{
17             (?> (?&PerlBlock) )
18             }],
19             ] => sub {
20 2     2   5 my ($m) = @_;
21 2         6 my ($kw, $meta, $ws, $block) = @{$m->submatches}{ qw(kw meta ws block) };
  2         44  
22              
23 2         30 $kw->replace_text('{ ' . $kw->text);
24 2         18 $meta->replace_text($meta->text . ';');
25 2         18 $ws->replace_text('');
26              
27 2         8 my $block_text = $block->text;
28 2         11 $block_text =~ s/\A\{//;
29 2         8 $block->replace_text($block_text);
30 2         30 });
31             }
32              
33             1;
34             __END__
35              
36             =head1 NAME
37              
38             Babble::Plugin::PackageBlock - Plugin for package block syntax
39              
40             =head1 SYNOPSIS
41              
42             Converts usage of the package block syntax from
43              
44             package NAMESPACE BLOCK
45              
46             to
47              
48             { package NAMESPACE; }
49              
50             =head1 SEE ALSO
51              
52             L<package-block syntax|Syntax::Construct/package-block>
53              
54             =cut