package votorola::b::Release;

use strict; use warnings;
=pod

=head1 DESCRIPTION

Release definitions.

=head1 EXPORTS

=over 4

=cut

BEGIN
{
    use Exporter ();
    our @ISA; @ISA = qw( Exporter );
    our @EXPORT_OK; @EXPORT_OK = qw( auto_edit_version auto_edit_version_last_released
      version version_last_released );
}
our @EXPORT_OK;



=pod

=item B<auto_edit_version>()

For embedded AutoEditor scripts, updates the first instance of C<version> found in the
begin line.  Dies if no such instance is found.

=cut

sub auto_edit_version() { _auto_edit_version( version() ); }



=pod

=item B<auto_edit_version_last_released>()

For embedded AutoEditor scripts, updates the first instance of C<version_last_released>
found in the begin line.  Dies if no such instance is found.

=cut

sub auto_edit_version_last_released() { _auto_edit_version( version_last_released() ); }



=pod

=item B<version>()

The current version of the code, for narrow release.  It is usually a quad in the form
"N.N.N.N", where N is a number.  It is a triple only when a wide release is made,
in which case it exactly matches C<version_last_released>.

=cut

sub version()
{
  # return version_last_released();
    return '0.2.3.1';
}



=pod

=item B<version_last_released>()

The last widely released version of the code.  Wide releases are always triples "N.N.N".

=cut

sub version_last_released() { return '0.2.3'; }



##### P r i v a t e ######################################################################


=pod

=item B<_auto_edit_version>( $version )

=cut

sub _auto_edit_version( $ )
{
    use votorola::b::AutoEditor qw( $begin @buffer $is_buffer_changed );
    my $v = shift;
    my $old_line = $buffer[$begin];
    $buffer[$begin] =~ s|\d+(?:\.\d+){2,3}|$v| or die;

    $is_buffer_changed = $buffer[$begin] ne $old_line;
}



=pod

=back

=cut

1;