App-DocKnot
view release on metacpan or search on metacpan
lib/App/DocKnot/Spin/Versions.pm view on Meta::CPAN
=for stopwords
Allbery DocKnot MERCHANTABILITY NONINFRINGEMENT sublicense YYYY-MM-DD
=head1 NAME
App::DocKnot::Spin::Versions - Parse package release information for spin
=head1 SYNOPSIS
use App::DocKnot::Spin::Versions;
my $versions = App::DocKnot::Spin::Versions('/path/to/.versions');
my $version = $versions->version('some-package');
my $release_date = $versions->release_date('some-package');
my $timestamp = $versions->latest_release('some/file/index.th');
=head1 REQUIREMENTS
Perl 5.24 or later and the Path::Tiny module, available from CPAN.
=head1 DESCRIPTION
App::DocKnot::Spin supports a database of release information for packages
that may be referenced in the generated web site. This is stored as the file
named F<.versions> at the top of the source tree. This module parses that
file and provides an API to the information it contains.
The file should consist of lines (except for continuation lines, see below) in
the form:
<package> <version> <date> <time> <files>
starting in the first column. Each field is separated by one or more spaces
except the last, <files>, which is all remaining space-separated words of the
line. Blank lines and lines starting with C<#> in the first column are
ignored.
The fields are:
=over 4
=item <package>
The name of a package.
=item <version>
The version number of the latest release of that package.
=item <date>
The date of the latest release of that package in YYYY-MM-DD format in the
local time zone.
=item <time>
The time of the latest release of that package in HH:MM:SS format in the local
time zone.
=item <files>
Any number of thread input files affected by this release, separated by
spaces. The file names should be relative to the top of the source tree for
the web site.
=back
The <files> field can be continued on the following line by starting the line
with whitespace. Each whitespace-separated word in a continuation line is
taken as an additional affected file for the previous line.
This information is used for the C<\version> and C<\release> thread commands
and to force regeneration of files affected by a release with a timestamp
newer than the timestamp of the corresponding output file.
=head1 CLASS METHODS
=over 4
=item new(PATH)
Create a new App::DocKnot::Spin::Versions object for the F<.versions> file
specified by PATH.
=back
=head1 INSTANCE METHODS
=over 4
=item latest_release(PATH)
Return the timestamp (in seconds since epoch) for the latest release affecting
PATH, or 0 if no releases affect that file.
=item release_date(PACKAGE)
Return the release date of the latest release of PACKAGE (in UTC), or C<undef>
if there is no release information for PACKAGE.
=item update_version(PACKAGE, VERSION, TIMESTAMP)
Given a new VERSION and TIMESTAMP (in seconds since epoch) for a release of
PACKAGE, update the release information in the F<.versions> file for that
package accordingly. If the F<.versions> file is at the root of a Git
repository, this change will be staged with C<git add>.
=item version(PACKAGE)
Return the version of the latest release of PACKAGE, or C<undef> if there is
no release information for PACKAGE.
=back
=head1 AUTHOR
Russ Allbery <rra@cpan.org>
=head1 COPYRIGHT AND LICENSE
Copyright 2004, 2021-2022 Russ Allbery <rra@cpan.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
( run in 0.478 second using v1.01-cache-2.11-cpan-39bf76dae61 )