line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::NamespaceMap::ReservedLocalParts; |
2
|
7
|
|
|
7
|
|
85541
|
use Moo 1.006000; |
|
7
|
|
|
|
|
9974
|
|
|
7
|
|
|
|
|
42
|
|
3
|
7
|
|
|
7
|
|
3620
|
use Types::Standard qw/ArrayRef Str/; |
|
7
|
|
|
|
|
64609
|
|
|
7
|
|
|
|
|
40
|
|
4
|
7
|
|
|
7
|
|
4827
|
use List::Util qw/first/; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1528
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has allowed => ( |
7
|
|
|
|
|
|
|
is => 'ro', |
8
|
|
|
|
|
|
|
isa => ArrayRef [Str], |
9
|
|
|
|
|
|
|
default => sub { [qw/allowed disallowed is_reserved/] } |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
has disallowed => (is => 'ro', isa => ArrayRef [Str], default => sub { [] }); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub is_reserved { |
14
|
60
|
|
|
60
|
1
|
4097
|
my ($self, $keyword) = @_; |
15
|
60
|
100
|
|
177
|
|
225
|
return 0 if first { $_ eq $keyword } @{$self->allowed}; |
|
177
|
|
|
|
|
287
|
|
|
60
|
|
|
|
|
223
|
|
16
|
57
|
100
|
|
52
|
|
194
|
return 1 if first { $_ eq $keyword } @{$self->disallowed}; |
|
52
|
|
|
|
|
115
|
|
|
57
|
|
|
|
|
144
|
|
17
|
56
|
100
|
|
|
|
488
|
return $self->can($keyword) ? 1 : 0; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
URI::NamespaceMap::ReservedLocalParts - Permissible local parts for NamespaceMap |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Version 1.10 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
say $r->is_reserved('isa'); # 1 |
39
|
|
|
|
|
|
|
say $r->is_reserved('uri'); # 1 |
40
|
|
|
|
|
|
|
say $r->is_reserved('foo'); # 0 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L<URI::NamespaceMap::ReservedLocalParts> is an accompanying distribution to |
45
|
|
|
|
|
|
|
L<URI::NamespaceMap>. It's goal is to check for forbidden names used for local |
46
|
|
|
|
|
|
|
parts. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Rather than creating a blacklist that needs to be maintained, it instantiates |
49
|
|
|
|
|
|
|
a new L<Moo> object, and calls C<can> on the invocant. Using this technique, it |
50
|
|
|
|
|
|
|
means that every method on every Perl object (C<isa, can, VERSION>), and Moo |
51
|
|
|
|
|
|
|
objects (C<BUILD, BUILDARGS>) will be automatically black listed. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
L<URI::NamespaceMap::ReservedLocalParts> implements the following attributes. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 allowed |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
A whitelist of local part names. Defaults to C<allowed>, C<disallowed> and |
60
|
|
|
|
|
|
|
C<is_reserved> so that when C<can> is called on the instance, it doesn't return |
61
|
|
|
|
|
|
|
a false positive for other method names associated with this package. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 disallowed |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
A blacklist of local part names. Does not have a default set, but usually |
66
|
|
|
|
|
|
|
defaults to C<uri> when called from L<URI::NamespaceMap>. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<URI::NamespaceMap::ReservedLocalParts> implements the following methods. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 is_reserved |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $r = URI::NamespaceMap::ReservedLocalParts->new(disallowed => [qw/uri/]); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
say $r->is_reserved('isa'); # 1 |
77
|
|
|
|
|
|
|
say $r->is_reserved('uri'); # 1 |
78
|
|
|
|
|
|
|
say $r->is_reserved('foo'); # 0 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Checks if the first argument passed is reserved or not. Returns a C<boolean>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 FURTHER DETAILS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
See L<URI::NamespaceMap> for further details about authors, license, etc. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |