Sah/Schema/filename.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« Sah/Schema/dirnames/exist.pm ↑ Summary Sah/Schema/filename/default_newest_file_in_curdir.pm »
1 package Sah::Schema::filename;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6 1 our $DATE = '2024-02-16'; # DATE
7 1 our $DIST = 'Sah-SchemaBundle-Path'; # DIST
8 1 our $VERSION = '0.031'; # VERSION
9  
10 1 our $schema = [str => {
11 summary => 'Filesystem file name',
12 description => <<'MARKDOWN',
13  
14 This schema is basically string with some checks and prefilters. Why use this
15 schema instead of plain ol' str? Mainly to give you the ability to change tilde
16 to user's home directory, e.g. `~/foo.txt` into `/home/someuser/foo.txt`.
17 Normally this expansion is done by a Unix shell, but sometimes your program
18 receives an unexpanded path, e.g. when you get it from some config file.
19  
20 See also more OS-specific schemas like `filename::unix`, which adds some more
21 checks (e.g. filename cannot contain forward slash and each component cannot be
22 longer than 255 characters) and preprocessing (e.g. stripping extraneous slashes
23 like `foo//bar` into `foo/bar`.
24  
25 What's the difference between this schema and `dirname`? The default completion
26 rule. `dirname`'s completion only includes directories and not files.
27  
28 MARKDOWN
29  
30 min_len => 1,
31  
32 'x.completion' => ['filename'],
33 prefilters => [
34 'Path::expand_tilde_when_on_unix',
35 'Path::strip_slashes_when_on_unix',
36 ],
37  
38 examples => [
39 {value=>'', valid=>0},
40 {value=>'foo', valid=>1},
41 {value=>'foo/bar', valid=>1},
42 ],
43  
44 }];
45  
46 1 1;
47 # ABSTRACT: Filesystem file name
48  
49 __END__
« Sah/Schema/dirnames/exist.pm ↑ Summary Sah/Schema/filename/default_newest_file_in_curdir.pm »