has_file( $rel_path )
Returns true when $rel_path (relative to root) exists on disk.
abs_path( $rel_path )
Returns the absolute filesystem path for $rel_path. Croaks if $rel_path contains .. as a path component (path traversal).
slurp( $rel_path )
Reads and returns the entire UTF-8 content of $rel_path. Croaks if the file does not exist.
perl_files( @dirs )
Returns an arrayref of paths (relative to root) for all Perl source files (.pm .pl .t .PL) found recursively under the given directories. Defaults to lib/, script/, bin/, t/.
lib_modules
Returns an arrayref of .pm paths (relative to root) found under lib/.
test_files
Returns an arrayref of .t paths (relative to root) found under t/.
git_root
Returns the git repository root, or undef if not in a git repo.
builder_file
Returns the name (relative to root) of the first found builder file, or undef.
find_files( $dir, $pattern )
Returns an arrayref of all files under $dir matching $pattern (a string suffix or a compiled regexp).
NAME
App::Project::Doctor::Context - Distro filesystem context passed to all checks
VERSION
0.01
SYNOPSIS
use App::Project::Doctor::Context;
my $ctx = App::Project::Doctor::Context->new(
root => '/path/to/my-dist',
verbose => 1,
);
my $modules = $ctx->lib_modules;
my $content = $ctx->slurp('lib/My/Module.pm')
if $ctx->has_file('lib/My/Module.pm');
DESCRIPTION
Encapsulates the distribution root path and provides filesystem helpers. All Check::* plugins receive an instance; they must not access the filesystem directly.
CONSTRUCTOR
new( %args )
my $ctx = App::Project::Doctor::Context->new(
root => '/path/to/dist', # must be an existing directory
verbose => 0,
);
Croaks when root is not an existing directory.
API SPECIFICATION
Input
root : String -- existing directory path default '.'
verbose : Bool default 0
Output
Blessed hashref of type App::Project::Doctor::Context.
ACCESSORS
root, verbose -- read-only.
METHODS
has_file( $rel_path )
API SPECIFICATION
Input
$rel_path : String
Output
Bool.
abs_path( $rel_path )
API SPECIFICATION
Input
$rel_path : String
Output
String -- absolute path.
slurp( $rel_path )
API SPECIFICATION
Input
$rel_path : String
Output
String -- UTF-8 file content.
perl_files( @dirs )
API SPECIFICATION
Input
@dirs : List of String (default: lib script bin t)
Output
ArrayRef[String] -- relative paths.
lib_modules
ArrayRef[String] -- .pm files under lib/.
test_files
ArrayRef[String] -- .t files under t/.
git_root
API SPECIFICATION
Input
None.
Output
String | undef.
builder_file
API SPECIFICATION
Input
None.
Output
String | undef -- first found of Makefile.PL Build.PL dist.ini cpanfile.
find_files( $dir, $pattern )
API SPECIFICATION
Input
$dir : String
$pattern : String | Regexp | undef
Output
ArrayRef[String] -- relative paths.
MESSAGES
Code | Trigger | Resolution
-----|---------|----------
(none currently defined)
FORMAL SPECIFICATION
Context == [ root : Path, verbose : Bool ]
has_file : Context x RelPath -> Bool
has_file ctx p == exists (root ctx / p)
slurp : Context x RelPath -> String
dom slurp == { (ctx, p) | has_file ctx p }
LIMITATIONS
git_root shells out to git; returns undef when git is not installed.
AUTHOR
Nigel Horne <njh@nigelhorne.com>
LICENSE
Copyright (C) 2026 Nigel Horne. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.