File Coverage

blib/lib/SortKey/Num/file_size.pm
Criterion Covered Total %
statement 8 15 53.3
branch 0 6 0.0
condition 0 2 0.0
subroutine 3 6 50.0
pod 0 2 0.0
total 11 31 35.4


line stmt bran cond sub pod time code
1             package SortKey::Num::file_size;
2              
3 1     1   262554 use 5.010001;
  1         5  
4 1     1   5 use strict;
  1         1  
  1         30  
5 1     1   5 use warnings;
  1         4  
  1         261  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-11-10'; # DATE
9             our $DIST = 'SortKey-Num-file_size'; # DIST
10             our $VERSION = '0.001'; # VERSION
11              
12             sub meta {
13             return +{
14 0     0 0   v => 1,
15             args => {
16             follow_symlink => {schema=>'bool*', default=>1},
17             },
18             };
19             }
20              
21             sub gen_keygen {
22 0     0 0   my %args = @_;
23              
24 0   0       my $follow_symlink = $args{follow_symlink} // 1;
25              
26             sub {
27 0 0   0     my $arg = @_ ? shift : $_;
28 0 0         my @st = $follow_symlink ? stat($arg) : lstat($arg);
29 0 0         @st ? $st[7] : undef;
30             }
31 0           }
32              
33             1;
34             # ABSTRACT: File size as sort key
35              
36             __END__