File Coverage

blib/lib/Path/Tiny/Glob.pm
Criterion Covered Total %
statement 28 30 93.3
branch 3 4 75.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 39 42 92.8


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.0.1';
5              
6 1     1   67270 use strict;
  1         10  
  1         28  
7 1     1   10 use warnings;
  1         2  
  1         24  
8              
9 1     1   821 use Path::Tiny;
  1         13279  
  1         50  
10              
11 1     1   447 use Path::Tiny::Glob::Visitor;
  1         4  
  1         41  
12              
13 1     1   463 use parent 'Exporter::Tiny';
  1         280  
  1         6  
14              
15             our @EXPORT = qw/ pathglob /;
16              
17 1     1   79 use experimental qw/ signatures postderef /;
  1         2  
  1         9  
18              
19 5     5 1 18779 sub pathglob( $glob ) {
  5         11  
  5         8  
20              
21             # let's figure out which type of path we have
22 5         18 my( $head, $rest ) = split '/', $glob, 2;
23              
24 5         9 my $dir;
25              
26 5 50       22 if ( $head =~ /^~/ ) {
    100          
27 0         0 $dir = path($head);
28 0         0 $glob = $rest;
29             }
30             elsif( $head eq '' ) {
31 1         6 $dir = Path::Tiny->rootdir;
32 1         43 $glob = $rest;
33             }
34             else {
35 4         13 $dir = path('.');
36             }
37              
38 5         235 return Path::Tiny::Glob::Visitor->new(
39             path => $dir,
40             globs => [ $glob ],
41             )->as_list;
42             }
43              
44             1;
45              
46             __END__