line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::MVP::Reader::Findable::ByExtension 2.200013; |
2
|
|
|
|
|
|
|
# ABSTRACT: a Findable Reader that looks for files by extension |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
8675
|
use Moose::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw(Config::MVP::Reader::Findable); |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4347
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =method default_extension |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod This method, B<which must be composed by classes including this role>, returns |
13
|
|
|
|
|
|
|
#pod the default extension used by files in the format this reader can read. |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod When the Finder tries to find configuration, it have a directory root and a |
16
|
|
|
|
|
|
|
#pod basename. Each (Findable) reader that it tries in turn will look for a file |
17
|
|
|
|
|
|
|
#pod F<basename.extension> in the root directory. If exactly one file is found, |
18
|
|
|
|
|
|
|
#pod that file is read. |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod =cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
requires 'default_extension'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#pod =method refined_location |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod This role provides a default implementation of the |
27
|
|
|
|
|
|
|
#pod L<C<refined_location>|Config::MVP::Reader::Findable/refined_location> method |
28
|
|
|
|
|
|
|
#pod required by Config::MVP::Reader. It will return a filename based on the |
29
|
|
|
|
|
|
|
#pod original location, if a file exists matching that location plus the reader's |
30
|
|
|
|
|
|
|
#pod C<default_extension>. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub refined_location { |
35
|
1
|
|
|
1
|
1
|
4
|
my ($self, $location) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
4
|
my $candidate_name = "$location." . $self->default_extension; |
38
|
1
|
50
|
33
|
|
|
26
|
return unless -r $candidate_name and -f _; |
39
|
1
|
|
|
|
|
5
|
return $candidate_name; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
7
|
no Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=pod |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=encoding UTF-8 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Config::MVP::Reader::Findable::ByExtension - a Findable Reader that looks for files by extension |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 2.200013 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 PERL VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
62
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
63
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
64
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
67
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
68
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
69
|
|
|
|
|
|
|
the minimum required perl. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 default_extension |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This method, B<which must be composed by classes including this role>, returns |
76
|
|
|
|
|
|
|
the default extension used by files in the format this reader can read. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
When the Finder tries to find configuration, it have a directory root and a |
79
|
|
|
|
|
|
|
basename. Each (Findable) reader that it tries in turn will look for a file |
80
|
|
|
|
|
|
|
F<basename.extension> in the root directory. If exactly one file is found, |
81
|
|
|
|
|
|
|
that file is read. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 refined_location |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This role provides a default implementation of the |
86
|
|
|
|
|
|
|
L<C<refined_location>|Config::MVP::Reader::Findable/refined_location> method |
87
|
|
|
|
|
|
|
required by Config::MVP::Reader. It will return a filename based on the |
88
|
|
|
|
|
|
|
original location, if a file exists matching that location plus the reader's |
89
|
|
|
|
|
|
|
C<default_extension>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo Signes. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |