line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Babble::Plugin::PackageVersion; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
69760
|
use Moo; |
|
1
|
|
|
|
|
7231
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
1980
|
use Data::Dumper; |
|
1
|
|
|
|
|
6819
|
|
|
1
|
|
|
|
|
330
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub transform_to_plain { |
7
|
9
|
|
|
9
|
0
|
7983
|
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
|
|
|
|
|
|
|
] => sub { |
26
|
7
|
|
|
7
|
|
14
|
my ($m) = @_; |
27
|
7
|
|
|
|
|
128
|
my $gr = $m->grammar_regexp; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my ($name, $ws, $version, $rest) = |
30
|
7
|
|
|
|
|
25
|
@{$m->submatches}{ qw(name ws version rest) }; |
|
7
|
|
|
|
|
160
|
|
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
29
|
$ws->replace_text(''); |
33
|
|
|
|
|
|
|
|
34
|
7
|
|
|
|
|
15
|
my $version_info = do { |
35
|
7
|
|
|
|
|
15
|
local $Data::Dumper::Terse = 1; |
36
|
7
|
|
|
|
|
13
|
local $Data::Dumper::Indent = 0; |
37
|
7
|
|
|
|
|
39
|
Dumper($version->text); |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
# not using line with $VERSION to avoid inaccurate VERSION detection |
40
|
7
|
|
|
|
|
439
|
my $version_statement = qq{our \044VERSION = }.$version_info.';'; |
41
|
7
|
|
|
|
|
29
|
$version->replace_text(''); |
42
|
|
|
|
|
|
|
|
43
|
7
|
100
|
|
|
|
32
|
if( $rest->text =~ /\A\{/ ) { |
44
|
2
|
|
|
|
|
16
|
$rest->transform_text(sub { s/\A \{ (?&PerlOWS) $gr/{\n${version_statement}\n/x }); |
|
2
|
|
|
|
|
64252
|
|
45
|
|
|
|
|
|
|
} else { |
46
|
5
|
|
|
|
|
34
|
$rest->transform_text(sub { s/\A ;? /;\n${version_statement}\n/x }); |
|
5
|
|
|
|
|
39
|
|
47
|
|
|
|
|
|
|
} |
48
|
9
|
|
|
|
|
98
|
}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Babble::Plugin::PackageVersion - Plugin for package version syntax |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Converts usage of the package version syntax from |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package NAMESPACE VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
to |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package NAMESPACE; |
67
|
|
|
|
|
|
|
$NAMESPACE::VERSION = VERSION; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SEE ALSO |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
L<package-version syntax|Syntax::Construct/package-version> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |