| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Articulate::Sortation::MetaDelver; |
|
2
|
2
|
|
|
2
|
|
1346
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
65
|
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
7
|
use Moo; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
|
|
with 'Articulate::Role::Sortation::AllYouNeedIsCmp'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1574
|
use Articulate::Syntax qw(instantiate dpath_get); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
11
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Articulate::Sortation::MetaDelver - delve into the metadata and sort it |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head3 options |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
A hashref defining what information to get and how to sort it. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item * C: . This field is mandatory. A C expression used to find the right field from the meta, e.g. 'schema/core/dateUpdated' Not that a '/' will be prepended if it does not already exist.. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item * C - The type of comparison to apply - any class which provides a C method can be entered here. Defaults to C. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item * C - The direction in which to sort: C or C, defaults to C. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=back |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 sort |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Provided by L. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 schwartz |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Provided by L. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has options => ( |
|
43
|
|
|
|
|
|
|
is => 'rw', |
|
44
|
|
|
|
|
|
|
default => sub { {} }, |
|
45
|
|
|
|
|
|
|
coerce => sub { |
|
46
|
|
|
|
|
|
|
my $orig = shift; |
|
47
|
|
|
|
|
|
|
$orig->{cmp} //= 'Articulate::Sortation::String'; |
|
48
|
|
|
|
|
|
|
$orig->{cmp} = instantiate ( $orig->{cmp} ); |
|
49
|
|
|
|
|
|
|
$orig->{field} //= '/'; |
|
50
|
|
|
|
|
|
|
$orig->{field} =~ s~^([^/].*)$~/$1~; |
|
51
|
|
|
|
|
|
|
$orig->{order} //= 'asc'; |
|
52
|
|
|
|
|
|
|
return $orig; |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub decorate { |
|
58
|
16
|
|
|
16
|
0
|
16
|
my $self = shift; |
|
59
|
16
|
|
|
|
|
10
|
my $item = shift; |
|
60
|
16
|
|
50
|
|
|
302
|
return ( dpath_get( $item->meta, $self->options->{field} ) // '' ) |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub cmp { |
|
64
|
10
|
|
|
10
|
1
|
12
|
my $self = shift; |
|
65
|
10
|
|
|
|
|
10
|
my $left = shift; |
|
66
|
10
|
|
|
|
|
7
|
my $right = shift; |
|
67
|
10
|
|
|
|
|
181
|
$self->options->{cmp}->cmp( $left, $right ) |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |