| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Deflator::PathClassFile; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | $HTML::FormFu::Deflator::PathClassFile::VERSION = '2.06'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Deflator for Path::Class::File objects | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | extends 'HTML::FormFu::Deflator'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | has relative => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | has absolute => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | has basename => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | sub deflator { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deflator: called CC=10 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | return $value unless ( ref $value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # we default to relative(1) | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | $self->relative(1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->absolute or $self->basename or $self->relative
$self->absolute or $self->basename
MC/DC100%3/3
$self->absolute or $self->basename or $self->relative
$self->absolute
$self->basename
$self->relative
Truth table100%4/4
A or B or C
A= $self->absoluteB= $self->basenameC= $self->relative
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | unless ( $self->absolute || $self->basename || $self->relative ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | if ( $self->relative ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | return $value->relative( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | $self->relative eq "1" ? undef : $self->relative )->stringify; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | elsif ( $self->absolute ) { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | return $value->absolute( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | $self->absolute eq "1" ? undef : $self->absolute )->stringify; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | elsif ( $self->basename ) { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | return $value->basename; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # fallback, should never happen | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $value->stringify; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | HTML::FormFu::Deflator::PathClassFile - Deflator for Path::Class::File objects | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | version 2.06 | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | $form->deflator( PathClassFile => 'file' ) | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ->relative( 'root' ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | --- | ||||||||||||||||||||||||||||||||||||||||||
| 63 | elements: | ||||||||||||||||||||||||||||||||||||||||||
| 64 | - type: Text | ||||||||||||||||||||||||||||||||||||||||||
| 65 | deflator: | ||||||||||||||||||||||||||||||||||||||||||
| 66 | - type: PathClassFile | ||||||||||||||||||||||||||||||||||||||||||
| 67 | relative: root | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | Deflator for Path::Class::File objects. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | There are three types of deflation: | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | =item relative | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | Set this to 1 to deflate to a relative path. Anything else than 1 specifies the | ||||||||||||||||||||||||||||||||||||||||||
| 80 | directory to use as the base of relativity - otherwise the current working | ||||||||||||||||||||||||||||||||||||||||||
| 81 | directory will be used. | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =item absolute | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Set this to 1 to deflate to an absolute path. Anything else than 1 specifies the | ||||||||||||||||||||||||||||||||||||||||||
| 86 | directory to use as the base of relativity - otherwise the current working | ||||||||||||||||||||||||||||||||||||||||||
| 87 | directory will be used. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | =item basename | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Set this to 1 to get the name of the file without the directory portion. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | As you cannot set values for a File element, this deflator will only work | ||||||||||||||||||||||||||||||||||||||||||
| 96 | on regular form elements. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | Moritz Onken, C<onken@houseofdesign.de> | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 105 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 116 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||||||||||||||||||||||||