Skip to content

Commit

Permalink
Support package version syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
syohex committed Jul 7, 2023
1 parent 7409bee commit 5d45bfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Module/BumpVersion.pm
Expand Up @@ -125,6 +125,10 @@ sub version_re_pod {
return qr{ ^ ( .*? (?i: version ) .*? ) $ver_re ( .* ) $ }x;
}

sub version_re_package {
my $ver_re = shift;
return qr{ ^ ( package \s+ \S+ \s+ ) $ver_re (.*) $ }x;
}

# State machine for Perl source
sub scanner{
Expand All @@ -143,6 +147,10 @@ sub scanner{
re => version_re_perl($ver_re),
mark => 1,
},
{
re => version_re_package($ver_re),
mark => 1,
},
],

# pod within perl
Expand Down Expand Up @@ -174,4 +182,3 @@ sub scanner{


1;

10 changes: 10 additions & 0 deletions t/bumpversion.t
Expand Up @@ -66,6 +66,16 @@ our $VERSION="v0.0.1"; # No BumpVersion
}
};

subtest 'package version syntax' => sub {
my $tmpfile = "$tmpdir/Foo.pm";
open my $fh, '>', $tmpfile or die $!;
print {$fh} q{
package Foo v0.0.1;
1;
};
close $fh;
test($tmpfile);
};

done_testing;

Expand Down

0 comments on commit 5d45bfa

Please sign in to comment.