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
|
|
64
|
|
|
5
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
use strict; |
7
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
82
|
|
8
|
5
|
|
|
5
|
|
21
|
|
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
173
|
|
9
|
|
|
|
|
|
|
use Hash::Util; |
10
|
5
|
|
|
5
|
|
2244
|
|
|
5
|
|
|
|
|
12328
|
|
|
5
|
|
|
|
|
28
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.16'; # TRIAL |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use overload '%{}' => \&tag_hash, fallback => 1; |
14
|
5
|
|
|
5
|
|
371
|
|
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
44
|
|
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
|
33
|
|
|
33
|
1
|
92
|
return bless { list => $target->_tag_list }, $class; |
39
|
|
|
|
|
|
|
} |
40
|
33
|
|
|
|
|
777
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
no overloading; |
56
|
27
|
|
|
27
|
1
|
16688
|
|
57
|
|
|
|
|
|
|
return $self->{tag_hash} ||= do { |
58
|
5
|
|
|
5
|
|
538
|
my %tags; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
640
|
|
59
|
|
|
|
|
|
|
for my $tuple ( @{ $self->{list} } ) { |
60
|
27
|
|
33
|
|
|
125
|
# my ( $tag, $attrs, $value ) = @$tuple; |
61
|
27
|
|
|
|
|
86
|
my $tag = ( $tags{ $tuple->[0] } ||= {} ); |
62
|
27
|
|
|
|
|
38
|
$tag->{$_} = $tuple->[2] for @{ $tuple->[1] }; |
|
27
|
|
|
|
|
130
|
|
63
|
|
|
|
|
|
|
} |
64
|
111
|
|
100
|
|
|
316
|
Hash::Util::lock_hash( %tags ); |
65
|
111
|
|
|
|
|
143
|
\%tags; |
|
111
|
|
|
|
|
349
|
|
66
|
|
|
|
|
|
|
}; |
67
|
27
|
|
|
|
|
104
|
} |
68
|
27
|
|
|
|
|
731
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
no overloading; |
84
|
|
|
|
|
|
|
|
85
|
11
|
|
|
11
|
1
|
17
|
return $self->{attr_hash} ||= do { |
86
|
|
|
|
|
|
|
my %attrs; |
87
|
5
|
|
|
5
|
|
31
|
for my $tuple ( @{ $self->{list} } ) { |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
677
|
|
88
|
|
|
|
|
|
|
# my ( $tag, $attrs, $value ) = @$tuple; |
89
|
11
|
|
66
|
|
|
42
|
( $attrs{$_} ||= {} )->{ $tuple->[0] } = $tuple->[2] |
90
|
6
|
|
|
|
|
8
|
for @{ $tuple->[1] }; |
91
|
6
|
|
|
|
|
7
|
} |
|
6
|
|
|
|
|
13
|
|
92
|
|
|
|
|
|
|
Hash::Util::lock_hash( %attrs ); |
93
|
|
|
|
|
|
|
\%attrs; |
94
|
36
|
|
100
|
|
|
44
|
}; |
|
36
|
|
|
|
|
113
|
|
95
|
|
|
|
|
|
|
} |
96
|
6
|
|
|
|
|
20
|
|
97
|
6
|
|
|
|
|
133
|
|
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
|
5
|
|
|
5
|
1
|
13
|
return $self->{tags} ||= [ keys %{ $self->tag_hash } ]; |
117
|
|
|
|
|
|
|
} |
118
|
5
|
|
|
5
|
|
35
|
|
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
659
|
|
119
|
|
|
|
|
|
|
return ( $self->{attr} ||= {} )->{$attr} ||= do { |
120
|
5
|
100
|
|
|
|
11
|
my $attrs = $self->attr_hash; |
121
|
1
|
|
50
|
|
|
4
|
[ keys %{ $attrs->{$attr} || {} } ]; |
|
1
|
|
|
|
|
3
|
|
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
} |
124
|
4
|
|
50
|
|
|
20
|
|
|
|
|
33
|
|
|
|
|
125
|
4
|
|
|
|
|
18
|
|
126
|
4
|
50
|
|
|
|
7
|
|
|
4
|
|
|
|
|
34
|
|
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
|
6
|
|
|
6
|
1
|
1536
|
# |
140
|
|
|
|
|
|
|
# This file is part of MooX-TaggedAttributes |
141
|
5
|
|
|
5
|
|
2158
|
# |
|
5
|
|
|
|
|
3415
|
|
|
5
|
|
|
|
|
20
|
|
142
|
6
|
|
|
|
|
13
|
# 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.16 |
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 |