• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Types/Path/H19-Apr-2018-27958

t/H19-Apr-2018-393331

xt/H19-Apr-2018-170111

CONTRIBUTING.mkdnH A D19-Apr-20183.4 KiB10165

ChangesH A D19-Apr-2018782 3317

LICENSEH A D19-Apr-201811.2 KiB208172

MANIFESTH A D19-Apr-2018495 2726

META.jsonH A D19-Apr-20183 KiB110108

META.ymlH A D19-Apr-20181.3 KiB5453

Makefile.PLH A D19-Apr-20181.6 KiB6857

READMEH A D19-Apr-20183.6 KiB13993

cpanfileH A D19-Apr-20181.4 KiB4843

dist.iniH A D19-Apr-2018319 1614

perlcritic.rcH A D19-Apr-2018630 2720

tidyall.iniH A D19-Apr-2018160 65

README

1NAME
2    Types::Path::Tiny - Path::Tiny types and coercions for Moose and Moo
3
4VERSION
5    version 0.006
6
7SYNOPSIS
8    Example with Moose:
9
10      ### specification of type constraint with coercion
11
12      package Foo;
13
14      use Moose;
15      use Types::Path::Tiny qw/Path AbsPath/;
16
17      has filename => (
18        is => 'ro',
19        isa => Path,
20        coerce => 1,
21      );
22
23      has directory => (
24        is => 'ro',
25        isa => AbsPath,
26        coerce => 1,
27      );
28
29      ### usage in code
30
31      Foo->new( filename => 'foo.txt' ); # coerced to Path::Tiny
32      Foo->new( directory => '.' ); # coerced to path('.')->absolute
33
34    Example with Moo:
35
36        ### specification of type constraint with coercion
37
38        package Foo;
39
40        use Moo;
41        use Types::Path::Tiny qw/Path AbsPath/;
42
43        has 'directory' => (
44            is       => 'rw',
45            isa      => AbsPath,
46            required => 1,
47            coerce   => AbsPath->coercion,
48        );
49
50        ### usage in code
51
52        Foo->new( directory => '.' ); # coerced to path('.')->absolute
53
54DESCRIPTION
55    This module provides Path::Tiny types for Moose, Moo, etc.
56
57    It handles two important types of coercion:
58
59    *   coercing objects with overloaded stringification
60
61    *   coercing to absolute paths
62
63    It also can check to ensure that files or directories exist.
64
65SUBTYPES
66    This module uses Type::Tiny to define the following subtypes.
67
68  Path
69    "Path" ensures an attribute is a Path::Tiny object. Strings and objects
70    with overloaded stringification may be coerced.
71
72  AbsPath
73    "AbsPath" is a subtype of "Path" (above), but coerces to an absolute
74    path.
75
76  File, AbsFile
77    These are just like "Path" and "AbsPath", except they check "-f" to
78    ensure the file actually exists on the filesystem.
79
80  Dir, AbsDir
81    These are just like "Path" and "AbsPath", except they check "-d" to
82    ensure the directory actually exists on the filesystem.
83
84CAVEATS
85  Path vs File vs Dir
86    "Path" just ensures you have a Path::Tiny object.
87
88    "File" and "Dir" check the filesystem. Don't use them unless that's
89    really what you want.
90
91  Usage with File::Temp
92    Be careful if you pass in a File::Temp object. Because the argument is
93    stringified during coercion into a Path::Tiny object, no reference to
94    the original File::Temp argument is held. Be sure to hold an external
95    reference to it to avoid immediate cleanup of the temporary file or
96    directory at the end of the enclosing scope.
97
98    A better approach is to use Path::Tiny's own "tempfile" or "tempdir"
99    constructors, which hold the reference for you.
100
101        Foo->new( filename => Path::Tiny->tempfile );
102
103SEE ALSO
104    *   Path::Tiny
105
106    *   Moose::Manual::Types
107
108SUPPORT
109  Bugs / Feature Requests
110    Please report any bugs or feature requests through the issue tracker at
111    <https://github.com/dagolden/types-path-tiny/issues>. You will be
112    notified automatically of any progress on your issue.
113
114  Source Code
115    This is open source software. The code repository is available for
116    public review and contribution under the terms of the license.
117
118    <https://github.com/dagolden/types-path-tiny>
119
120      git clone https://github.com/dagolden/types-path-tiny.git
121
122AUTHOR
123    David Golden <dagolden@cpan.org>
124
125CONTRIBUTORS
126    *   Hobbestigrou <hobbestigrou@erakis.eu>
127
128    *   Hobbestigrou <natal.ngetal@novapost.fr>
129
130    *   Toby Inkster <tobyink@cpan.org>
131
132COPYRIGHT AND LICENSE
133    This software is Copyright (c) 2013 by David Golden.
134
135    This is free software, licensed under:
136
137      The Apache License, Version 2.0, January 2004
138
139