line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Path::Resolver::Resolver::Mux::Ordered 3.100455; |
2
|
|
|
|
|
|
|
# ABSTRACT: multiplex resolvers by checking them in order |
3
|
1
|
|
|
1
|
|
892
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5895
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
64
|
use MooseX::Types; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
3570
|
use MooseX::Types::Moose qw(Any ArrayRef); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod my $resolver = Path::Resolver::Resolver::Mux::Ordered->new({ |
13
|
|
|
|
|
|
|
#pod resolvers => [ |
14
|
|
|
|
|
|
|
#pod $resolver_1, |
15
|
|
|
|
|
|
|
#pod $resolver_2, |
16
|
|
|
|
|
|
|
#pod ... |
17
|
|
|
|
|
|
|
#pod ], |
18
|
|
|
|
|
|
|
#pod }); |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod This resolver looks in each of its resolvers in order and returns the result of |
23
|
|
|
|
|
|
|
#pod the first of its sub-resolvers to find the named entity. If no entity is |
24
|
|
|
|
|
|
|
#pod found, it returns false as usual. |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod The default native type of this resolver is Any, meaning that is is much more |
27
|
|
|
|
|
|
|
#pod lax than other resolvers. A C<native_type> can be specified while creating the |
28
|
|
|
|
|
|
|
#pod resolver. |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =attr resolvers |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod This is an array of other resolvers. When asked for content, the Mux::Ordered |
33
|
|
|
|
|
|
|
#pod resolver will check each resolver in this array and return the first found |
34
|
|
|
|
|
|
|
#pod content, or false if none finds any content. |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =method unshift_resolver |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod This method will add a resolver to the beginning of the list of consulted |
39
|
|
|
|
|
|
|
#pod resolvers. |
40
|
|
|
|
|
|
|
#pod |
41
|
|
|
|
|
|
|
#pod =method push_resolver |
42
|
|
|
|
|
|
|
#pod |
43
|
|
|
|
|
|
|
#pod This method will add a resolver to the end of the list of consulted resolvers. |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod =cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has resolvers => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => ArrayRef[ role_type('Path::Resolver::Role::Resolver') ], |
50
|
|
|
|
|
|
|
required => 1, |
51
|
|
|
|
|
|
|
auto_deref => 1, |
52
|
|
|
|
|
|
|
traits => ['Array'], |
53
|
|
|
|
|
|
|
handles => { |
54
|
|
|
|
|
|
|
push_resolver => 'push', |
55
|
|
|
|
|
|
|
unshift_resolver => 'unshift', |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has native_type => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => class_type('Moose::Meta::TypeConstraint'), |
62
|
|
|
|
|
|
|
default => sub { Any }, |
63
|
|
|
|
|
|
|
required => 1, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
with 'Path::Resolver::Role::Resolver'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub entity_at { |
69
|
|
|
|
|
|
|
my ($self, $path) = @_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
for my $resolver ($self->resolvers) { |
72
|
|
|
|
|
|
|
my $entity = $resolver->entity_at($path); |
73
|
|
|
|
|
|
|
next unless defined $entity; |
74
|
|
|
|
|
|
|
return $entity; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding UTF-8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Path::Resolver::Resolver::Mux::Ordered - multiplex resolvers by checking them in order |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 VERSION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
version 3.100455 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $resolver = Path::Resolver::Resolver::Mux::Ordered->new({ |
99
|
|
|
|
|
|
|
resolvers => [ |
100
|
|
|
|
|
|
|
$resolver_1, |
101
|
|
|
|
|
|
|
$resolver_2, |
102
|
|
|
|
|
|
|
... |
103
|
|
|
|
|
|
|
], |
104
|
|
|
|
|
|
|
}); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $simple_entity = $resolver->entity_at('foo/bar.txt'); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This resolver looks in each of its resolvers in order and returns the result of |
109
|
|
|
|
|
|
|
the first of its sub-resolvers to find the named entity. If no entity is |
110
|
|
|
|
|
|
|
found, it returns false as usual. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The default native type of this resolver is Any, meaning that is is much more |
113
|
|
|
|
|
|
|
lax than other resolvers. A C<native_type> can be specified while creating the |
114
|
|
|
|
|
|
|
resolver. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 PERL VERSION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This library should run on perls released even a long time ago. It should work |
119
|
|
|
|
|
|
|
on any version of perl released in the last five years. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
122
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
123
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
124
|
|
|
|
|
|
|
the minimum required perl. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 resolvers |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is an array of other resolvers. When asked for content, the Mux::Ordered |
131
|
|
|
|
|
|
|
resolver will check each resolver in this array and return the first found |
132
|
|
|
|
|
|
|
content, or false if none finds any content. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 METHODS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 unshift_resolver |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This method will add a resolver to the beginning of the list of consulted |
139
|
|
|
|
|
|
|
resolvers. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 push_resolver |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This method will add a resolver to the end of the list of consulted resolvers. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Ricardo Signes <cpan@semiotic.systems> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo Signes. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
154
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |