Skip to content

Commit

Permalink
Update the Data.pm version from the RangeMessage.xml date
Browse files Browse the repository at this point in the history
  • Loading branch information
briandfoy committed Mar 18, 2023
1 parent 0edadef commit 73959b7
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion examples/make_default_data.pl
Expand Up @@ -77,6 +77,38 @@ =head1 COPYRIGHT AND LICENSE

my $data = Business::ISBN::Data::_parse_range_message( $file );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
# Thu, 16 Mar 2023 20:59:31 GMT
my( $day, $mon, $year ) = $data->{_date} =~ m/
# Thu, 16 Mar 2023 20:59:31 GMT
\A
\S+?
, \s+
(?<day> \d+ ) \s
(?<mon> [a-z]+ ) \s
(?<year> \d+ )
/x;

my $new_version_date = sprintf '%4d%02d%02d', @+{qw(year mon day)};
my $current_date = Business::ISBN::Data->VERSION;
my( $major, $minor ) = split /\./, $current_date;

my $new_minor = do {
if( $new_version_date > $major ) { 1 }
elsif( $new_version_date == $major ) { $minor + 1 }
else {
die "New date ($new_version_date) is older than current version ($current_date)\n";
}
};

my $new_version = sprintf '%s.%03d', $new_version_date, $new_minor;
say "CURRENT VERSION: $current_date NEW VERSION: $new_version";

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
my $string = "\t(\n";

foreach my $key ( sort grep /^_/, keys %$data ) {
Expand Down Expand Up @@ -105,6 +137,9 @@ =head1 COPYRIGHT AND LICENSE
$string =~ s/%%$k%%/$s/;
}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
my $PM_FILE = 'lib/Business/ISBN/Data.pm';
my $TEMP_FILE = 'lib/Business/ISBN/Data.pm.tmp';

Expand All @@ -115,7 +150,11 @@ =head1 COPYRIGHT AND LICENSE

while(<$in_fh>) {
state $in_replace = 0;
if( /\A# BEGIN REPLACE/ ) {
if( s/\$VERSION = \K'\d+\.\d+'/'$new_version'/ ) {
print {$out_fh} $_;
next;
}
elsif( /\A# BEGIN REPLACE/ ) {
$in_replace = 1;
print {$out_fh} $_;
next;
Expand Down

0 comments on commit 73959b7

Please sign in to comment.