line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Path::Resolver::Resolver::FileSystem 3.100455; |
2
|
|
|
|
|
|
|
# ABSTRACT: find files in the filesystem |
3
|
1
|
|
|
1
|
|
530
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
with 'Path::Resolver::Role::FileResolver'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5788
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
70
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
9
|
1
|
|
|
1
|
|
4
|
use Cwd (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
10
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
182
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod my $resolver = Path::Resolver::Resolver::FileSystem->new({ |
15
|
|
|
|
|
|
|
#pod root => '/etc/myapp_config', |
16
|
|
|
|
|
|
|
#pod }); |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod This resolver looks for files on disk under the given root directory. |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod This resolver does the |
23
|
|
|
|
|
|
|
#pod L<Path::Resolver::Role::FileResolver|Path::Resolver::Role::FileResolver> role, |
24
|
|
|
|
|
|
|
#pod meaning its native type is Path::Resolver::Types::AbsFilePath and it has a |
25
|
|
|
|
|
|
|
#pod default converter to convert to Path::Resolver::SimpleEntity. |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod =attr root |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod This is the root on the filesystem under which to look. If it is relative, it |
30
|
|
|
|
|
|
|
#pod will be resolved to an absolute path when the resolver is instantiated. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has root => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
default => sub { Cwd::cwd }, |
38
|
|
|
|
|
|
|
initializer => sub { |
39
|
|
|
|
|
|
|
my ($self, $value, $set) = @_; |
40
|
|
|
|
|
|
|
my $abs_dir = File::Spec->rel2abs($value); |
41
|
|
|
|
|
|
|
$set->($abs_dir); |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub entity_at { |
46
|
|
|
|
|
|
|
my ($self, $path) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $abs_path = File::Spec->catfile( |
49
|
|
|
|
|
|
|
$self->root, |
50
|
|
|
|
|
|
|
@$path, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return unless -e $abs_path and -f _; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Path::Class::File->new($abs_path); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Path::Resolver::Resolver::FileSystem - find files in the filesystem |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 3.100455 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $resolver = Path::Resolver::Resolver::FileSystem->new({ |
77
|
|
|
|
|
|
|
root => '/etc/myapp_config', |
78
|
|
|
|
|
|
|
}); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This resolver looks for files on disk under the given root directory. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This resolver does the |
85
|
|
|
|
|
|
|
L<Path::Resolver::Role::FileResolver|Path::Resolver::Role::FileResolver> role, |
86
|
|
|
|
|
|
|
meaning its native type is Path::Resolver::Types::AbsFilePath and it has a |
87
|
|
|
|
|
|
|
default converter to convert to Path::Resolver::SimpleEntity. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 PERL VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This library should run on perls released even a long time ago. It should work |
92
|
|
|
|
|
|
|
on any version of perl released in the last five years. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
95
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
96
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
97
|
|
|
|
|
|
|
the minimum required perl. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 root |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This is the root on the filesystem under which to look. If it is relative, it |
104
|
|
|
|
|
|
|
will be resolved to an absolute path when the resolver is instantiated. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo Signes. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |