Sah/Schema/dirname.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
« Data/Sah/Filter/perl/Path/strip_slashes_when_on_unix.pm ↑ Summary Sah/Schema/dirname/default_curdir.pm »
1 package Sah::Schema::dirname;
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 directory 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` into `/home/someuser/foo`. Normally this
17 expansion is done by a Unix shell, but sometimes your program receives an
18 unexpanded path, e.g. when you get it from some config file.
19  
20 See also more OS-specific schemas like `dirname::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 `filename`? The default completion
26 rule. This schema's completion by default only includes directories.
27  
28 MARKDOWN
29  
30 min_len => 1,
31  
32 'x.completion' => ['dirname'],
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 directory name
48  
49 __END__
« Data/Sah/Filter/perl/Path/strip_slashes_when_on_unix.pm ↑ Summary Sah/Schema/dirname/default_curdir.pm »