logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

App::DocKnot::Util - Shared utility functions for other DocKnot modules

Author

       Russ Allbery <rra@cpan.org>

Description

       This module collects utility functions used by other App::DocKnot modules.  It is not really intended for
       use outside of DocKnot, but these functions can be used if desired.

Functions

       is_newer(FILE, SOURCE[, SOURCE ...])
           Returns  a  true value if FILE exists and has a last modified time that is newer or equal to the last
           modified times of all SOURCE files, and otherwise returns a false value.  Used primarily to determine
           if a given output file is up-to-date with respect to its source files.  All paths must be  Path::Tiny
           objects.

       latest_tarball(PATH, NAME)
           Returns  data  including a file list for the latest tarballs (by version number) for a given software
           package NAME in the directory PATH (which must be a Path::Tiny object).  Versions are compared  using
           Sort::Versions.  The return valid is a hash with the following keys:

           files
               The list of files found for that version.

           version
               The version number extracted from this set of files.

       print_checked(ARG[, ARG ...])
           The same as print (without a file handle argument), except that it throws a text exception on failure
           as if autodie affected print (which it unfortunately doesn't because print cannot be prototyped).

       print_fh(FH, NAME, DATA[, DATA ...])
           Writes  the concatenation of the DATA elements (interpreted as scalar strings) to the file handle FH.
           NAME should be the name of (or Path::Tiny object for) the file open as FH,  and  is  used  for  error
           reporting.

           This is mostly equivalent to "print {fh}" but throws a text exception in the event of a failure.

Name

       App::DocKnot::Util - Shared utility functions for other DocKnot modules

Requirements

       Perl 5.24 or later and the modules List::SomeUtils, Path::Tiny, and Sort::Versions, available from CPAN.

See Also

       App::DocKnot

       This module is part of the App-DocKnot distribution.  The current version of DocKnot  is  available  from
       CPAN, or directly from its web site at <https://www.eyrie.org/~eagle/software/docknot/>.

perl v5.38.2                                       2024-07-14                            App::DocKnot::Util(3pm)

Synopsis

           use App::DocKnot::Util qw(
               is_newer latest_tarball print_checked print_fh
           );
           use Path::Tiny qw(path);

           print_checked('some stdout output');
           my @inputs = (path('/input-1'), path('/input-2'));
           if (!is_newer(path('/output'), @inputs)) {
               open(my $fh, '>', '/output');
               print_fh($fh, '/output', 'some stuff');
               close($fh);
           }

           my $latest_ref = latest_tarball(path('/archive'), 'App-Foo');

See Also