File Coverage

blib/lib/Path/Tiny/Glob.pm
Criterion Covered Total %
statement 41 42 97.6
branch 10 12 83.3
condition 2 3 66.6
subroutine 10 10 100.0
pod 1 1 100.0
total 64 68 94.1


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.2.0';
5              
6 3     3   541023 use strict;
  3         17  
  3         70  
7 3     3   12 use warnings;
  3         5  
  3         56  
8              
9 3     3   2023 use Path::Tiny;
  3         27268  
  3         122  
10              
11 3     3   1157 use Path::Tiny::Glob::Visitor;
  3         12  
  3         96  
12              
13 3     3   1125 use parent 'Exporter::Tiny';
  3         721  
  3         17  
14              
15             our @EXPORT = qw/ pathglob /;
16             our @EXPORT_OK = qw/ is_globby /;
17              
18 3     3   221 use experimental qw/ signatures postderef /;
  3         6  
  3         14  
19              
20             sub _generate_pathglob {
21 3     3   468 my( $class, undef, $args ) = @_;
22              
23 1     1   2 return sub(@) { return _pathglob(@_)->all }
  1         4  
  1         69  
24 3 50 66     20 if $args && $args->{all};
25              
26 2         8 return \&_pathglob;
27             }
28              
29 9     9   28236 sub _pathglob( $glob ) {
  9         17  
  9         12  
30              
31 9 100       33 my @glob = ref $glob eq 'ARRAY' ? @$glob : ($glob);
32              
33             @glob = map {
34 9 100       18 ref ? $_ : split '/', $_, -1;
  10         53  
35             } @glob;
36              
37 9         13 my $dir;
38              
39 9 50       30 if ( $glob[0] =~ /^~/ ) {
    100          
40 0         0 $dir = path(shift @glob);
41             }
42             elsif( $glob[0] eq '' ) {
43 1         5 $dir = Path::Tiny->rootdir;
44 1         36 shift @glob;
45             }
46             else {
47 8         25 $dir = path('.');
48             }
49              
50 9 100       246 unless( ref $glob[-1] ) {
51              
52             }
53              
54 9         156 return Path::Tiny::Glob::Visitor->new(
55             path => $dir,
56             globs => [ \@glob ],
57             )->as_list;
58             }
59              
60 3     3 1 5931 sub is_globby($string) {
  3         6  
  3         3  
61 3         15 return $string =~ /[?*]/;
62             }
63              
64             1;
65              
66             __END__