1MooseX::Types::Path::TiUnsye(r3pCmo)ntributed Perl DocumMeonotsaetXi:o:nTypes::Path::Tiny(3pm)
2
3
4

NAME

6       MooseX::Types::Path::Tiny - Path::Tiny types and coercions for Moose
7

VERSION

9       version 0.012
10

SYNOPSIS

12         ### specification of type constraint with coercion
13
14         package Foo;
15
16         use Moose;
17         use MooseX::Types::Path::Tiny qw/Path Paths AbsPath/;
18
19         has filename => (
20           is => 'ro',
21           isa => Path,
22           coerce => 1,
23         );
24
25         has directory => (
26           is => 'ro',
27           isa => AbsPath,
28           coerce => 1,
29         );
30
31         has filenames => (
32           is => 'ro',
33           isa => Paths,
34           coerce => 1,
35         );
36
37         ### usage in code
38
39         Foo->new( filename => 'foo.txt' ); # coerced to Path::Tiny
40         Foo->new( directory => '.' ); # coerced to path('.')->absolute
41         Foo->new( filenames => [qw/bar.txt baz.txt/] ); # coerced to ArrayRef[Path::Tiny]
42

DESCRIPTION

44       This module provides Path::Tiny types for Moose.  It handles two
45       important types of coercion:
46
47       ·   coercing objects with overloaded stringification
48
49       ·   coercing to absolute paths
50
51       It also can check to ensure that files or directories exist.
52

SUBTYPES

54       This module uses MooseX::Types to define the following subtypes.
55
56   Path
57       "Path" ensures an attribute is a Path::Tiny object.  Strings and
58       objects with overloaded stringification may be coerced.
59
60   AbsPath
61       "AbsPath" is a subtype of "Path" (above), but coerces to an absolute
62       path.
63
64   File, AbsFile
65       These are just like "Path" and "AbsPath", except they check "-f" to
66       ensure the file actually exists on the filesystem.
67
68   Dir, AbsDir
69       These are just like "Path" and "AbsPath", except they check "-d" to
70       ensure the directory actually exists on the filesystem.
71
72   Paths, AbsPaths
73       These are arrayrefs of "Path" and "AbsPath", and include coercions from
74       arrayrefs of strings.
75

CAVEATS

77   Path vs File vs Dir
78       "Path" just ensures you have a Path::Tiny object.
79
80       "File" and "Dir" check the filesystem.  Don't use them unless that's
81       really what you want.
82
83   Usage with File::Temp
84       Be careful if you pass in a File::Temp object. Because the argument is
85       stringified during coercion into a Path::Tiny object, no reference to
86       the original File::Temp argument is held.  Be sure to hold an external
87       reference to it to avoid immediate cleanup of the temporary file or
88       directory at the end of the enclosing scope.
89
90       A better approach is to use Path::Tiny's own "tempfile" or "tempdir"
91       constructors, which hold the reference for you.
92
93           Foo->new( filename => Path::Tiny->tempfile );
94

SEE ALSO

96       ·   Path::Tiny
97
98       ·   Moose::Manual::Types
99
100       ·   Types::Path::Tiny
101

SUPPORT

103       Bugs may be submitted through the RT bug tracker
104       <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Path-
105       Tiny> (or bug-MooseX-Types-Path-Tiny@rt.cpan.org <mailto:bug-MooseX-
106       Types-Path-Tiny@rt.cpan.org>).
107
108       There is also a mailing list available for users of this distribution,
109       at <http://lists.perl.org/list/moose.html>.
110
111       There is also an irc channel available for users of this distribution,
112       at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
113
114       I am also usually active on irc, as 'ether' at "irc.perl.org".
115

AUTHOR

117       David Golden <dagolden@cpan.org>
118

CONTRIBUTORS

120       ·   Karen Etheridge <ether@cpan.org>
121
122       ·   Toby Inkster <mail@tobyinkster.co.uk>
123
124       ·   Demian Riccardi <dde@ornl.gov>
125
126       ·   Gregory Oschwald <goschwald@maxmind.com>
127
129       This software is Copyright (c) 2013 by David Golden.
130
131       This is free software, licensed under:
132
133         The Apache License, Version 2.0, January 2004
134
135
136
137perl v5.32.0                      2020-07-28    MooseX::Types::Path::Tiny(3pm)
Impressum