Types::Path::Tiny(3)
hiii bestie π you just opened the Types::Path::Tiny(3) manual β yeah, the User Contributed Perl Documentation one β and Iβm gonna explain it like weβre texting. no cap, this is the module that gives you Path::Tiny types and coercions for Moose, Moo, etc. π¦
π NAME π
Types::Path::Tiny β Path::Tiny types and coercions for Moose and Moo. periodt. β¨
πΈ VERSION πΈ
okay so the version is literally version 0.006 π
β¨ SYNOPSIS β¨
Example with Moose:
### specification of type constraint with coercion
package Foo;
use Moose;
use Types::Path::Tiny qw/Path AbsPath/;
has filename => (
is => 'ro',
isa => Path,
coerce => 1,
);
has directory => (
is => 'ro',
isa => AbsPath,
coerce => 1,
);
### usage in code
Foo->new( filename => 'foo.txt' ); # coerced to Path::Tiny
Foo->new( directory => '.' ); # coerced to path('.')->absolute
Example with Moo:
### specification of type constraint with coercion
package Foo;
use Moo;
use Types::Path::Tiny qw/Path AbsPath/;
has 'directory' => (
is => 'rw',
isa => AbsPath,
required => 1,
coerce => AbsPath->coercion,
);
### usage in code
Foo->new( directory => '.' ); # coerced to path('.')->absolute
π¦ DESCRIPTION π¦
okay so Types::Path::Tiny provides Path::Tiny types for Moose, Moo, etc. π
It handles two important types of coercion:
- coercing objects with overloaded stringification πͺ
- coercing to absolute paths π£οΈ
It also can check to ensure that files or directories exist. lowkey useful. π
π SUBTYPES π
This module uses Type::Tiny to define the following subtypes.
π Path π
Path ensures an attribute is a Path::Tiny object. Strings and objects with overloaded stringification may be coerced.
π AbsPath π
AbsPath is a subtype of Path (above), but coerces to an absolute path.
π File, AbsFile π
These are just like Path and AbsPath, except they check -f to ensure the file actually exists on the filesystem. yes, for real. π
π Dir, AbsDir π
These are just like Path and AbsPath, except they check -d to ensure the directory actually exists on the filesystem.
β οΈ CAVEATS β οΈ
π¨ Path vs File vs Dir π¨
Path just ensures you have a Path::Tiny object.
File and Dir check the filesystem. Donβt use them unless thatβs really what you want.
bestie, that is the whole warning.FileandDirare doing an actual filesystem check, so use them only when you mean it. π«Ά
π Usage with File::Temp π
Be careful if you pass in a File::Temp object. Because the argument is stringified during coercion into a Path::Tiny object, no reference to the original File::Temp argument is held. Be sure to hold an external reference to it to avoid immediate cleanup of the temporary file or directory at the end of the enclosing scope. ππ
A better approach is to use Path::Tinyβs own tempfile or tempdir constructors, which hold the reference for you.
Foo->new( filename => Path::Tiny->tempfile );
π SEE ALSO π
Path::TinyπMoose::Manual::Typesπ
π«Ά SUPPORT π«Ά
π Bugs / Feature Requests π
Please report any bugs or feature requests through the issue tracker at <https://github.com/dagolden/types-path-tiny/issues>. You will be notified automatically of any progress on your issue. no ghosting. π»
π§ Source Code π§
This is open source software. The code repository is available for public review and contribution under the terms of the license.
<https://github.com/dagolden/types-path-tiny>
git clone https://github.com/dagolden/types-path-tiny.git
π AUTHOR π
David Golden <dagolden@cpan.org> β author icon π
πΈ CONTRIBUTORS πΈ
- Hobbestigrou
<hobbestigrou@erakis.eu> - Hobbestigrou
<natal.ngetal@novapost.fr> - Toby Inkster
<tobyink@cpan.org>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
okay thatβs the whole page, bestie π«Ά the footer says perl v5.42.0 and 2018-04-20, and this manual is Types::Path::Tiny(3). byeee π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Types-Path-Tiny 0.006-bp160.1.12 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms