Data/Sah/Filter/perl/Path/expand_tilde_when_on_unix.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Data/Sah/Filter/perl/Path/strip_slashes.pm ↑ Summary Data/Sah/Filter/perl/Path/strip_slashes_when_on_unix.pm »
1 package Data::Sah::Filter::perl::Path::expand_tilde_when_on_unix;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶use Perl::osnames;
Subroutine BEGIN: called CC=1 SCAR=2.6
8  
9 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
10 our $DATE = '2024-02-16'; # DATE
11 our $DIST = 'Sah-SchemaBundle-Path'; # DIST
12 our $VERSION = '0.031'; # VERSION
13  
14 sub meta {
15 +{
16 v => 1,
17 target_type => 'str',
18 summary => "Expand tilde ('~' and '~USER' to user's home directory)",
19 };
20 }
21  
22 sub filter {
23 my %args = @_;
24  
25 my $dt = $args{data_term};
26  
27 my $res = {};
28  
29 $res->{expr_filter} = join(
30 "",
31 "do { my \$tmp = $dt; if (\$^O =~ qr/$Perl::osnames::RE_OS_IS_UNIX/) { \$tmp =~ s!\\A~([^/]*)!my \@pw = length(\$1) ? getpwnam(\$1) : getpwuid(\$>); \@pw ? \$pw[7]: \"~\$1\"!e; } \$tmp }",
32 );
33  
34 $res;
35 }
36  
37 1;
38 # ABSTRACT:
39  
40 __END__
« Data/Sah/Filter/perl/Path/strip_slashes.pm ↑ Summary Data/Sah/Filter/perl/Path/strip_slashes_when_on_unix.pm »