line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# ABSTRACT: Extract information from a Tagged Attribute Cache |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use v5.10.1; |
5
|
5
|
|
|
5
|
|
55
|
|
|
5
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
use strict; |
7
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
85
|
|
8
|
5
|
|
|
5
|
|
47
|
|
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
147
|
|
9
|
|
|
|
|
|
|
use Hash::Util; |
10
|
5
|
|
|
5
|
|
2373
|
|
|
5
|
|
|
|
|
12174
|
|
|
5
|
|
|
|
|
29
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.17'; # TRIAL |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use overload '%{}' => \&tag_hash, fallback => 1; |
14
|
5
|
|
|
5
|
|
370
|
|
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
46
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my ( $class, $target ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
66
|
|
|
66
|
1
|
133
|
return bless { list => $target->_tag_list }, $class; |
39
|
|
|
|
|
|
|
} |
40
|
66
|
|
|
|
|
1521
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
no overloading; |
56
|
54
|
|
|
54
|
1
|
25047
|
|
57
|
|
|
|
|
|
|
return $self->{tag_hash} ||= do { |
58
|
5
|
|
|
5
|
|
521
|
my %tags; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
671
|
|
59
|
|
|
|
|
|
|
for my $tuple ( @{ $self->{list} } ) { |
60
|
54
|
|
33
|
|
|
195
|
# my ( $tag, $attrs, $value ) = @$tuple; |
61
|
54
|
|
|
|
|
136
|
my $tag = ( $tags{ $tuple->[0] } ||= {} ); |
62
|
54
|
|
|
|
|
95
|
$tag->{$_} = $tuple->[2] for @{ $tuple->[1] }; |
|
54
|
|
|
|
|
140
|
|
63
|
|
|
|
|
|
|
} |
64
|
224
|
|
100
|
|
|
632
|
Hash::Util::lock_hash( %tags ); |
65
|
224
|
|
|
|
|
277
|
\%tags; |
|
224
|
|
|
|
|
611
|
|
66
|
|
|
|
|
|
|
}; |
67
|
54
|
|
|
|
|
177
|
} |
68
|
54
|
|
|
|
|
1297
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
no overloading; |
84
|
|
|
|
|
|
|
|
85
|
22
|
|
|
22
|
1
|
27
|
return $self->{attr_hash} ||= do { |
86
|
|
|
|
|
|
|
my %attrs; |
87
|
5
|
|
|
5
|
|
32
|
for my $tuple ( @{ $self->{list} } ) { |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
699
|
|
88
|
|
|
|
|
|
|
# my ( $tag, $attrs, $value ) = @$tuple; |
89
|
22
|
|
66
|
|
|
90
|
( $attrs{$_} ||= {} )->{ $tuple->[0] } = $tuple->[2] |
90
|
12
|
|
|
|
|
14
|
for @{ $tuple->[1] }; |
91
|
12
|
|
|
|
|
18
|
} |
|
12
|
|
|
|
|
26
|
|
92
|
|
|
|
|
|
|
Hash::Util::lock_hash( %attrs ); |
93
|
|
|
|
|
|
|
\%attrs; |
94
|
72
|
|
100
|
|
|
82
|
}; |
|
72
|
|
|
|
|
231
|
|
95
|
|
|
|
|
|
|
} |
96
|
12
|
|
|
|
|
38
|
|
97
|
12
|
|
|
|
|
260
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my ( $self, $attr ) = @_; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
no overloading; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
if ( !defined $attr ) { |
116
|
10
|
|
|
10
|
1
|
22
|
return $self->{tags} ||= [ keys %{ $self->tag_hash } ]; |
117
|
|
|
|
|
|
|
} |
118
|
5
|
|
|
5
|
|
33
|
|
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
663
|
|
119
|
|
|
|
|
|
|
return ( $self->{attr} ||= {} )->{$attr} ||= do { |
120
|
10
|
100
|
|
|
|
23
|
my $attrs = $self->attr_hash; |
121
|
2
|
|
50
|
|
|
10
|
[ keys %{ $attrs->{$attr} || {} } ]; |
|
2
|
|
|
|
|
5
|
|
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
} |
124
|
8
|
|
50
|
|
|
43
|
|
|
|
|
33
|
|
|
|
|
125
|
8
|
|
|
|
|
17
|
|
126
|
8
|
50
|
|
|
|
11
|
|
|
8
|
|
|
|
|
68
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my ( $self, $attr, $tag ) = @_; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
no autovivification; |
136
|
|
|
|
|
|
|
return $self->attr_hash->{$attr}{$tag}; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
12
|
|
|
12
|
1
|
3252
|
# |
140
|
|
|
|
|
|
|
# This file is part of MooX-TaggedAttributes |
141
|
5
|
|
|
5
|
|
2029
|
# |
|
5
|
|
|
|
|
3407
|
|
|
5
|
|
|
|
|
19
|
|
142
|
12
|
|
|
|
|
27
|
# This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
143
|
|
|
|
|
|
|
# |
144
|
|
|
|
|
|
|
# This is free software, licensed under: |
145
|
|
|
|
|
|
|
# |
146
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=pod |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=for :stopwords Diab Jerius Smithsonian Astrophysical Observatory |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 NAME |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
MooX::TaggedAttributes::Cache - Extract information from a Tagged Attribute Cache |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 VERSION |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
version 0.17 |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 SYNOPSIS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
$cache = MooX::TaggedAttributes::Cache->new( $class ); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
$tags = $cache->tags; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 DESCRIPTION |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L<MooX::TaggedAttributes> caches attribute tags as objects of this class. |
171
|
|
|
|
|
|
|
The user typically never instantiates objects of L<MooX::TaggedAttributes::Cache>. |
172
|
|
|
|
|
|
|
Instead, they are returned by the L<_tags|MooX::TaggedAttributes/_tags> method added |
173
|
|
|
|
|
|
|
to tagged classes, e.g. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
$cache = $class->_tags; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 CLASS METHODS |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 new |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
$cache = MooX::TaggedAttributes::Cache( $class ); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Create a cache object for the C<$class>, which must have a C<_tag_list> method. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 METHODS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 tag_hash |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
$tags = $cache->tag_hash; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Returns a reference to a hash keyed off of the tags in the cache. The |
192
|
|
|
|
|
|
|
values are hashes which map attribute names to tag values. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
B<Do Not Modify This Hash.> |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 attr_hash |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
$tags = $cache->tag_hash; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Returns a reference to a hash keyed off of the attributes in the |
201
|
|
|
|
|
|
|
cache. The values are hashes which map tag names to tag values. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
B<Do Not Modify This Hash.> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 tags |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# return all of the tags as an array reference |
208
|
|
|
|
|
|
|
$tags = $cache->tags; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# return the tags for the specified attribute as an array reference |
211
|
|
|
|
|
|
|
$tags = $cache->tags( $attr ); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Returns a reference to an array containing tags. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
B<Do Not Modify This Array.> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 value |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
$value = $cache->value( $attr, $tag ); |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Return the value of a tag for the given attribute. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 OVERLOAD |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head2 %{} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
The object may be treated as a hash reference. It will operate on the |
228
|
|
|
|
|
|
|
reference returned by L</tag_hash>. For example, |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
keys %{ $cache }; |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
is equivalent to |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
keys %{ $cache->tag_hash }; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 SUPPORT |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head2 Bugs |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Please report any bugs or feature requests to bug-moox-taggedattributes@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=MooX-TaggedAttributes |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head2 Source |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Source is available at |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
https://gitlab.com/djerius/moox-taggedattributes |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
and may be cloned from |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
https://gitlab.com/djerius/moox-taggedattributes.git |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SEE ALSO |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=over 4 |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item * |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
L<MooX::TaggedAttributes|MooX::TaggedAttributes> |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 AUTHOR |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Diab Jerius <djerius@cpan.org> |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
This is free software, licensed under: |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |