File Coverage

blib/lib/Path/Tiny/Glob.pm
Criterion Covered Total %
statement 35 36 97.2
branch 9 10 90.0
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 54 56 96.4


line stmt bran cond sub pod time code
1             package Path::Tiny::Glob;
2             our $AUTHORITY = 'cpan:YANICK';
3             # ABSTRACT: File globbing utility
4             $Path::Tiny::Glob::VERSION = '0.1.0';
5              
6 2     2   387364 use strict;
  2         13  
  2         60  
7 2     2   9 use warnings;
  2         4  
  2         49  
8              
9 2     2   1621 use Path::Tiny;
  2         23464  
  2         111  
10              
11 2     2   919 use Path::Tiny::Glob::Visitor;
  2         10  
  2         83  
12              
13 2     2   944 use parent 'Exporter::Tiny';
  2         599  
  2         13  
14              
15             our @EXPORT = qw/ pathglob /;
16             our @EXPORT_OK = qw/ is_globby /;
17              
18 2     2   184 use experimental qw/ signatures postderef /;
  2         4  
  2         12  
19              
20 6     6 1 23227 sub pathglob( $glob ) {
  6         13  
  6         10  
21              
22 6 100       26 my @glob = ref $glob eq 'ARRAY' ? @$glob : ($glob);
23              
24             @glob = map {
25 6 100       13 ref ? $_ : split '/', $_, -1;
  7         40  
26             } @glob;
27              
28 6         12 my $dir;
29              
30 6 50       21 if ( $glob[0] =~ /^~/ ) {
    100          
31 0         0 $dir = path(shift @glob);
32             }
33             elsif( $glob[0] eq '' ) {
34 1         7 $dir = Path::Tiny->rootdir;
35 1         45 shift @glob;
36             }
37             else {
38 5         17 $dir = path('.');
39             }
40              
41 6 100       177 unless( ref $glob[-1] ) {
42              
43             }
44              
45 6         143 return Path::Tiny::Glob::Visitor->new(
46             path => $dir,
47             globs => [ \@glob ],
48             )->as_list;
49             }
50              
51 3     3 1 7535 sub is_globby($string) {
  3         6  
  3         4  
52 3         20 return $string =~ /[?*]/;
53             }
54              
55             1;
56              
57             __END__