| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Path::Resolver::Resolver::DataSection 3.100455; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: find content in a package's Data::Section content |
|
3
|
1
|
|
|
1
|
|
494
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
with 'Path::Resolver::Role::Resolver'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5773
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
74
|
use File::Spec::Unix; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Moose::Util::TypeConstraints; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
10
|
1
|
|
|
1
|
|
1809
|
use Path::Resolver::SimpleEntity; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
246
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
7
|
|
|
7
|
0
|
21
|
sub native_type { class_type('Path::Resolver::SimpleEntity') } |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
#pod |
|
16
|
|
|
|
|
|
|
#pod my $resolver = Path::Resolver::Resolver::DataSection->new({ |
|
17
|
|
|
|
|
|
|
#pod module => 'YourApp::Config::InData', |
|
18
|
|
|
|
|
|
|
#pod }); |
|
19
|
|
|
|
|
|
|
#pod |
|
20
|
|
|
|
|
|
|
#pod my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
|
21
|
|
|
|
|
|
|
#pod |
|
22
|
|
|
|
|
|
|
#pod This class assumes that you will give it the name of another package and that |
|
23
|
|
|
|
|
|
|
#pod that package uses L<Data::Section|Data::Section> to retrieve named content from |
|
24
|
|
|
|
|
|
|
#pod its C<DATA> blocks and those of its parent classes. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod The native type of this resolver is a class type of |
|
27
|
|
|
|
|
|
|
#pod L<Path::Resolver::SimpleEntity|Path::Resolver::SimpleEntity> and it has no |
|
28
|
|
|
|
|
|
|
#pod default converter. |
|
29
|
|
|
|
|
|
|
#pod |
|
30
|
|
|
|
|
|
|
#pod =attr module |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod This is the name of the module to load and is also used as the package (class) |
|
33
|
|
|
|
|
|
|
#pod on which to call the data-finding method. |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod =cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has module => ( |
|
38
|
|
|
|
|
|
|
is => 'ro', |
|
39
|
|
|
|
|
|
|
isa => 'Str', |
|
40
|
|
|
|
|
|
|
required => 1, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#pod =attr data_method |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod This attribute may be given to supply a method name to call to find content in |
|
46
|
|
|
|
|
|
|
#pod a package. The default is Data::Section's default: C<section_data>. |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod =cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has data_method => ( |
|
51
|
|
|
|
|
|
|
is => 'ro', |
|
52
|
|
|
|
|
|
|
isa => 'Str', |
|
53
|
|
|
|
|
|
|
default => 'section_data', |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub BUILD { |
|
57
|
1
|
|
|
1
|
0
|
651
|
my ($self) = @_; |
|
58
|
1
|
|
|
|
|
31
|
my $module = $self->module; |
|
59
|
1
|
50
|
|
|
|
55
|
eval "require $module; 1" or die; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub entity_at { |
|
63
|
|
|
|
|
|
|
my ($self, $path) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $filename = File::Spec::Unix->catfile(@$path); |
|
66
|
|
|
|
|
|
|
my $method = $self->data_method; |
|
67
|
|
|
|
|
|
|
my $content_ref = $self->module->$method($filename); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return unless defined $content_ref; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return Path::Resolver::SimpleEntity->new({ content_ref => $content_ref }); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=encoding UTF-8 |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Path::Resolver::Resolver::DataSection - find content in a package's Data::Section content |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 3.100455 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $resolver = Path::Resolver::Resolver::DataSection->new({ |
|
93
|
|
|
|
|
|
|
module => 'YourApp::Config::InData', |
|
94
|
|
|
|
|
|
|
}); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This class assumes that you will give it the name of another package and that |
|
99
|
|
|
|
|
|
|
that package uses L<Data::Section|Data::Section> to retrieve named content from |
|
100
|
|
|
|
|
|
|
its C<DATA> blocks and those of its parent classes. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The native type of this resolver is a class type of |
|
103
|
|
|
|
|
|
|
L<Path::Resolver::SimpleEntity|Path::Resolver::SimpleEntity> and it has no |
|
104
|
|
|
|
|
|
|
default converter. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 PERL VERSION |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This library should run on perls released even a long time ago. It should work |
|
109
|
|
|
|
|
|
|
on any version of perl released in the last five years. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
|
112
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
|
113
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
|
114
|
|
|
|
|
|
|
the minimum required perl. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 module |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is the name of the module to load and is also used as the package (class) |
|
121
|
|
|
|
|
|
|
on which to call the data-finding method. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 data_method |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This attribute may be given to supply a method name to call to find content in |
|
126
|
|
|
|
|
|
|
a package. The default is Data::Section's default: C<section_data>. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo Signes. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |