| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Articulate::Navigation; |
|
2
|
4
|
|
|
4
|
|
2671
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
186
|
|
|
3
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
115
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
20
|
use Moo; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1206
|
use Articulate::Location; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
35
|
|
|
9
|
4
|
|
|
4
|
|
1880
|
use Articulate::LocationSpecification; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
31
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Articulate::Navigation - determine valid locations |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
components: |
|
18
|
|
|
|
|
|
|
navigation: |
|
19
|
|
|
|
|
|
|
Articulate::Navigation: |
|
20
|
|
|
|
|
|
|
locations: |
|
21
|
|
|
|
|
|
|
- zone/* |
|
22
|
|
|
|
|
|
|
- zone/*/article/* |
|
23
|
|
|
|
|
|
|
- user/* |
|
24
|
|
|
|
|
|
|
- [] |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Provides validation for locations. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ATTRIBUTE |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head3 locations |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Any location specifications configured in the locations attribute are valid locations for deposition and retrieval of items from storage. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has locations => ( |
|
37
|
|
|
|
|
|
|
is => 'rw', # rwp? |
|
38
|
|
|
|
|
|
|
default => sub{ [] }, |
|
39
|
|
|
|
|
|
|
coerce => sub{ |
|
40
|
|
|
|
|
|
|
my $orig = shift; |
|
41
|
|
|
|
|
|
|
my $new = []; |
|
42
|
|
|
|
|
|
|
foreach my $l (@{ $orig }){ |
|
43
|
|
|
|
|
|
|
push @$new, locspec $l; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
return $new; |
|
46
|
|
|
|
|
|
|
}, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# A locspec is like a location except it can contain "*": "/zone/*/article/" |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head3 valid_location |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
do_something if $self->valid_location('zone/public') |
|
58
|
|
|
|
|
|
|
do_something if $self->valid_location($location_object) |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the location if valid (matches one of the locspecs in C), undef otherwise. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub valid_location { |
|
65
|
101
|
|
|
101
|
1
|
4550
|
my $self = shift; |
|
66
|
101
|
|
|
|
|
248
|
my $location = loc shift; |
|
67
|
101
|
|
|
|
|
241
|
foreach my $defined_location ( @{ $self->locations } ) { |
|
|
101
|
|
|
|
|
1949
|
|
|
68
|
190
|
100
|
|
|
|
2023
|
if ( $defined_location->matches($location) ) { |
|
69
|
101
|
|
|
|
|
367
|
return $location; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
0
|
|
|
|
|
|
return undef; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head3 define_locspec |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$self->define_locspec('zone/*') |
|
78
|
|
|
|
|
|
|
$self->define_locspec($locspec) |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Adds a locspec to C, unless it is already there |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub define_locspec { |
|
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
87
|
0
|
|
|
|
|
|
my $location = locspec shift; |
|
88
|
0
|
|
|
|
|
|
foreach my $defined_location ( @{ $self->locations } ) { |
|
|
0
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if ( ( $location eq $defined_location ) ) { |
|
90
|
0
|
|
|
|
|
|
return undef; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
|
push @{ $self->locations }, $location; |
|
|
0
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head3 undefine_locspec |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$self->undefine_locspec('zone/*') |
|
99
|
|
|
|
|
|
|
$self->undefine_locspec($locspec) |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Removes a locspec from C. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub undefine_locspec { |
|
107
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
108
|
0
|
|
|
|
|
|
my $location = locspec shift; |
|
109
|
0
|
|
|
|
|
|
my ($removed, $kept) = ([], []); |
|
110
|
0
|
|
|
|
|
|
foreach my $defined_location ( @{ $self->locations } ){ |
|
|
0
|
|
|
|
|
|
|
|
111
|
0
|
0
|
0
|
|
|
|
if ( ( $location eq $defined_location ) or $defined_location->matches_descendant_of($location) ) { |
|
112
|
0
|
|
|
|
|
|
push @$removed, $location; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
else { |
|
115
|
0
|
|
|
|
|
|
push @$kept, $location; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
0
|
|
|
|
|
|
$self->locations($kept); |
|
119
|
0
|
|
|
|
|
|
return $removed; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * L |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * L |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |