Movatterモバイル変換


[0]ホーム

URL:


 / 
Types-Path-Tiny-0.006
River stage three • 50 direct dependents • 317 total dependents
/Types::Path::Tiny

NAME

Types::Path::Tiny - Path::Tiny types and coercions for Moose and Moo

VERSION

version 0.006

SYNOPSIS

Example with Moose:

### specification of type constraint with coercionpackage 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 codeFoo->new( filename => 'foo.txt' ); # coerced to Path::TinyFoo->new( directory => '.' ); # coerced to path('.')->absolute

Example with Moo:

### specification of type constraint with coercionpackage Foo;use Moo;use Types::Path::Tiny qw/Path AbsPath/;has 'directory' => (    is       => 'rw',    isa      => AbsPath,    required => 1,    coerce   => AbsPath->coercion,);### usage in codeFoo->new( directory => '.' ); # coerced to path('.')->absolute

DESCRIPTION

This module providesPath::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.

SUBTYPES

This module usesType::Tiny to define the following subtypes.

Path

Path ensures an attribute is aPath::Tiny object. Strings and objects with overloaded stringification may be coerced.

AbsPath

AbsPath is a subtype ofPath (above), but coerces to an absolute path.

File, AbsFile

These are just likePath andAbsPath, except they check-f to ensure the file actually exists on the filesystem.

Dir, AbsDir

These are just likePath andAbsPath, except they check-d to ensure the directory actually exists on the filesystem.

CAVEATS

Path vs File vs Dir

Path just ensures you have aPath::Tiny object.

File andDir check the filesystem. Don't use them unless that's really what you want.

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 owntempfile ortempdir constructors, which hold the reference for you.

Foo->new( filename => Path::Tiny->tempfile );

SEE ALSO

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker athttps://github.com/dagolden/types-path-tiny/issues. You will be notified automatically of any progress on your issue.

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>

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

Module Install Instructions

To install Types::Path::Tiny, copy and paste the appropriate command in to your terminal.

cpanm

cpanm Types::Path::Tiny

CPAN shell

perl -MCPAN -e shellinstall Types::Path::Tiny

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp