line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Specio::Library::Path::Tiny; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
139549
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Path::Tiny 0.087; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
41
|
|
9
|
1
|
|
|
1
|
|
427
|
use Specio 0.28 (); |
|
1
|
|
|
|
|
98
|
|
|
1
|
|
|
|
|
15
|
|
10
|
1
|
|
|
1
|
|
4
|
use Specio::Declare; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
123
|
use Specio::Library::Builtins; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
4329
|
use parent 'Specio::Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
declare( |
16
|
|
|
|
|
|
|
'Path', |
17
|
|
|
|
|
|
|
parent => object_isa_type('Path::Tiny'), |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
declare( |
21
|
|
|
|
|
|
|
'AbsPath', |
22
|
|
|
|
|
|
|
parent => t('Path'), |
23
|
|
|
|
|
|
|
inline => sub { |
24
|
|
|
|
|
|
|
return sprintf( |
25
|
|
|
|
|
|
|
'( %s && %s->is_absolute )', |
26
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
27
|
|
|
|
|
|
|
$_[1] |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
declare( |
33
|
|
|
|
|
|
|
'RealPath', |
34
|
|
|
|
|
|
|
parent => t('Path'), |
35
|
|
|
|
|
|
|
inline => sub { |
36
|
|
|
|
|
|
|
return sprintf( |
37
|
|
|
|
|
|
|
'( %s && %s->realpath eq %s )', |
38
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
39
|
|
|
|
|
|
|
$_[1], $_[1] |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
}, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
declare( |
45
|
|
|
|
|
|
|
'File', |
46
|
|
|
|
|
|
|
parent => t('Path'), |
47
|
|
|
|
|
|
|
inline => sub { |
48
|
|
|
|
|
|
|
return sprintf( |
49
|
|
|
|
|
|
|
'( %s && %s->is_file )', |
50
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
51
|
|
|
|
|
|
|
$_[1] |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
declare( |
57
|
|
|
|
|
|
|
'AbsFile', |
58
|
|
|
|
|
|
|
parent => t('Path'), |
59
|
|
|
|
|
|
|
inline => sub { |
60
|
|
|
|
|
|
|
return sprintf( |
61
|
|
|
|
|
|
|
'( %s && %s->is_file && %s->is_absolute )', |
62
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
63
|
|
|
|
|
|
|
$_[1], $_[1] |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
declare( |
69
|
|
|
|
|
|
|
'RealFile', |
70
|
|
|
|
|
|
|
parent => t('Path'), |
71
|
|
|
|
|
|
|
inline => sub { |
72
|
|
|
|
|
|
|
return sprintf( |
73
|
|
|
|
|
|
|
'( %s && %s->is_file && %s->realpath eq %s )', |
74
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
75
|
|
|
|
|
|
|
$_[1], $_[1], $_[1] |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
declare( |
81
|
|
|
|
|
|
|
'Dir', |
82
|
|
|
|
|
|
|
parent => t('Path'), |
83
|
|
|
|
|
|
|
inline => sub { |
84
|
|
|
|
|
|
|
return sprintf( |
85
|
|
|
|
|
|
|
'( %s && %s->is_dir )', |
86
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
87
|
|
|
|
|
|
|
$_[1] |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
}, |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
declare( |
93
|
|
|
|
|
|
|
'AbsDir', |
94
|
|
|
|
|
|
|
parent => t('Path'), |
95
|
|
|
|
|
|
|
inline => sub { |
96
|
|
|
|
|
|
|
return sprintf( |
97
|
|
|
|
|
|
|
'( %s && %s->is_dir && %s->is_absolute )', |
98
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
99
|
|
|
|
|
|
|
$_[1], $_[1], |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
}, |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
declare( |
105
|
|
|
|
|
|
|
'RealDir', |
106
|
|
|
|
|
|
|
parent => t('Path'), |
107
|
|
|
|
|
|
|
inline => sub { |
108
|
|
|
|
|
|
|
return sprintf( |
109
|
|
|
|
|
|
|
'( %s && %s->is_dir && %s->realpath eq %s )', |
110
|
|
|
|
|
|
|
$_[0]->parent->inline_check( $_[1] ), |
111
|
|
|
|
|
|
|
$_[1], $_[1], $_[1] |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
}, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
for my $type ( map { t($_) } qw( Path File Dir ) ) { |
117
|
|
|
|
|
|
|
coerce( |
118
|
|
|
|
|
|
|
$type, |
119
|
|
|
|
|
|
|
from => t('Str'), |
120
|
|
|
|
|
|
|
inline => sub {"Path::Tiny::path( $_[1] )"}, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
coerce( |
124
|
|
|
|
|
|
|
$type, |
125
|
|
|
|
|
|
|
from => t('ArrayRef'), |
126
|
|
|
|
|
|
|
inline => sub {"Path::Tiny::path( \@{ $_[1] } )"}, |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
for my $type ( map { t($_) } qw( AbsPath AbsFile AbsDir ) ) { |
131
|
|
|
|
|
|
|
coerce( |
132
|
|
|
|
|
|
|
$type, |
133
|
|
|
|
|
|
|
from => t('Path'), |
134
|
|
|
|
|
|
|
inline => sub { sprintf( '%s->absolute', $_[1] ) }, |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
coerce( |
138
|
|
|
|
|
|
|
$type, |
139
|
|
|
|
|
|
|
from => t('Str'), |
140
|
|
|
|
|
|
|
inline => |
141
|
|
|
|
|
|
|
sub { sprintf( 'Path::Tiny::path( %s )->absolute', $_[1] ) }, |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
coerce( |
145
|
|
|
|
|
|
|
$type, |
146
|
|
|
|
|
|
|
from => t('ArrayRef'), |
147
|
|
|
|
|
|
|
inline => |
148
|
|
|
|
|
|
|
sub { sprintf( 'Path::Tiny::path( @{ %s } )->absolute', $_[1] ) }, |
149
|
|
|
|
|
|
|
); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
for my $type ( map { t($_) } qw( RealPath RealFile RealDir ) ) { |
153
|
|
|
|
|
|
|
coerce( |
154
|
|
|
|
|
|
|
$type, |
155
|
|
|
|
|
|
|
from => t('Path'), |
156
|
|
|
|
|
|
|
inline => sub { sprintf( '%s->realpath', $_[1] ) }, |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
coerce( |
160
|
|
|
|
|
|
|
$type, |
161
|
|
|
|
|
|
|
from => t('Str'), |
162
|
|
|
|
|
|
|
inline => |
163
|
|
|
|
|
|
|
sub { sprintf( 'Path::Tiny::path( %s )->realpath', $_[1] ) }, |
164
|
|
|
|
|
|
|
); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
coerce( |
167
|
|
|
|
|
|
|
$type, |
168
|
|
|
|
|
|
|
from => t('ArrayRef'), |
169
|
|
|
|
|
|
|
inline => |
170
|
|
|
|
|
|
|
sub { sprintf( 'Path::Tiny::path( @{ %s } )->realpath', $_[1] ) }, |
171
|
|
|
|
|
|
|
); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# ABSTRACT: Path::Tiny types and coercions for Specio |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=pod |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=encoding UTF-8 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 NAME |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Specio::Library::Path::Tiny - Path::Tiny types and coercions for Specio |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 VERSION |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
version 0.03 |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 SYNOPSIS |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
use Specio::Library::Path::Tiny; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
has path => ( isa => t('Path') ); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 DESCRIPTION |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
This library provides a set of L<Path::Tiny> types and coercions for |
201
|
|
|
|
|
|
|
L<Specio>. These types can be used with L<Moose>, L<Moo>, |
202
|
|
|
|
|
|
|
L<Params::ValidationCompiler>, and other modules. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 TYPES |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This library provides the following types: |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 Path |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
A L<Path::Tiny> object. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path>. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 AbsPath |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
A L<Path::Tiny> object where C<< $path->is_absolute >> returns true. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
219
|
|
|
|
|
|
|
call to C<< $path->absolute >>. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 RealPath |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
A L<Path::Tiny> object where C<< $path->realpath eq $path >>. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
226
|
|
|
|
|
|
|
call to C<< $path->realpath >>. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 File |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a file on disk according to C<< $path->is_file |
231
|
|
|
|
|
|
|
>>. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path>. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 AbsFile |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a file on disk according to C<< $path->is_file |
238
|
|
|
|
|
|
|
>> where C<< $path->is_absolute >> returns true. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
241
|
|
|
|
|
|
|
call to C<< $path->absolute >>. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 RealFile |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a file on disk according to C<< $path->is_file |
246
|
|
|
|
|
|
|
>> where C<< $path->realpath eq $path >>. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
249
|
|
|
|
|
|
|
call to C<< $path->realpath >>. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head2 Dir |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a directory on disk according to C<< |
254
|
|
|
|
|
|
|
$path->is_dir >>. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path>. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head2 AbsDir |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a directory on disk according to C<< |
261
|
|
|
|
|
|
|
$path->is_dir >> where C<< $path->is_absolute >> returns true. |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
264
|
|
|
|
|
|
|
call to C<< $path->absolute >>. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 RealDir |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
A L<Path::Tiny> object which is a directory on disk according to C<< |
269
|
|
|
|
|
|
|
$path->is_dir >> where C<< $path->realpath eq $path >>. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Will be coerced from a string or arrayref via C<Path::Tiny::path> followed by |
272
|
|
|
|
|
|
|
call to C<< $path->realpath >>. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 CREDITS |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
The vast majority of the code in this distribution comes from David Golden's |
277
|
|
|
|
|
|
|
L<Types::Path::Tiny> distribution. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 SUPPORT |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|http://rt.cpan.org/Public/Dist/Display.html?Name=Specio-Library-Path-Tiny> |
282
|
|
|
|
|
|
|
(or L<bug-specio-library-path-tiny@rt.cpan.org|mailto:bug-specio-library-path-tiny@rt.cpan.org>). |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
I am also usually active on IRC as 'drolsky' on C<irc://irc.perl.org>. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 DONATIONS |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
If you'd like to thank me for the work I've done on this module, please |
289
|
|
|
|
|
|
|
consider making a "donation" to me via PayPal. I spend a lot of free time |
290
|
|
|
|
|
|
|
creating free software, and would appreciate any support you'd care to offer. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Please note that B<I am not suggesting that you must do this> in order for me |
293
|
|
|
|
|
|
|
to continue working on this particular software. I will continue to do so, |
294
|
|
|
|
|
|
|
inasmuch as I have in the past, for as long as it interests me. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Similarly, a donation made in this way will probably not make me work on this |
297
|
|
|
|
|
|
|
software much more, unless I get so many donations that I can consider working |
298
|
|
|
|
|
|
|
on free software full time (let's all have a chuckle at that together). |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
To donate, log into PayPal and send money to autarch@urth.org, or use the |
301
|
|
|
|
|
|
|
button at L<http://www.urth.org/~autarch/fs-donation.html>. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head1 AUTHOR |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by Dave Rolsky. |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
This is free software, licensed under: |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=cut |