line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::PMP::CollectionDoc::Links; |
2
|
3
|
|
|
3
|
|
19
|
use Moose; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
26
|
|
3
|
3
|
|
|
3
|
|
17035
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
179
|
|
4
|
3
|
|
|
3
|
|
18
|
use Data::Dump qw( dump ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
112
|
|
5
|
3
|
|
|
3
|
|
982
|
use Net::PMP::CollectionDoc::Link; |
|
3
|
|
|
|
|
45
|
|
|
3
|
|
|
|
|
110
|
|
6
|
3
|
|
|
3
|
|
1273
|
use Net::PMP::CollectionDoc::Permission; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
1153
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'links' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'ArrayRef', |
13
|
|
|
|
|
|
|
required => 1, |
14
|
|
|
|
|
|
|
trigger => \&_bless_links |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
has 'type' => ( is => 'rw', isa => 'Str', required => 1, ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %link_blacklist = ( 'href-vars' => 1, 'href-template' => 1, 'meta' => 1 ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _bless_links { |
23
|
0
|
|
|
0
|
|
|
my ( $self, $links ) = @_; |
24
|
0
|
|
|
|
|
|
for my $link (@$links) { |
25
|
0
|
0
|
|
|
|
|
next if blessed $link; |
26
|
0
|
|
|
|
|
|
my %h = (); |
27
|
0
|
|
|
|
|
|
for my $attr ( keys %$link ) { |
28
|
0
|
0
|
|
|
|
|
next if exists $link_blacklist{$attr}; |
29
|
0
|
|
|
|
|
|
$h{$attr} = $link->{$attr}; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
0
|
|
|
|
|
if ( $link->{'meta'} ) { |
32
|
0
|
|
|
|
|
|
$h{media_meta} = $link->{'meta'}; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
0
|
|
|
|
|
if ( $link->{'href-vars'} ) { |
35
|
0
|
|
|
|
|
|
$h{vars} = $link->{'href-vars'}; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
0
|
|
|
|
|
if ( $link->{'href-template'} ) { |
38
|
0
|
|
|
|
|
|
$h{template} = $link->{'href-template'}; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
0
|
|
|
|
|
if ( $self->type eq 'permission' ) { |
41
|
0
|
|
|
|
|
|
$link = Net::PMP::CollectionDoc::Permission->new(%h); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
$link = Net::PMP::CollectionDoc::Link->new(%h); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
return $links; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub query_rel_types { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
if ( $self->type ne 'query' ) { |
53
|
0
|
|
|
|
|
|
croak "Can't call query_rel_types on Links object of type " |
54
|
|
|
|
|
|
|
. $self->type; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
my %t; |
57
|
0
|
|
|
|
|
|
for my $link ( @{ $self->links } ) { |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$t{ $link->{rels}->[0] } = $link->{title}; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
|
return \%t; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub rels { |
64
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
65
|
0
|
|
|
|
|
|
my @urns = @_; |
66
|
0
|
|
|
|
|
|
my @links; |
67
|
0
|
|
|
|
|
|
for my $urn (@urns) { |
68
|
0
|
|
|
|
|
|
for my $link ( @{ $self->links } ) { |
|
0
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
for my $rel ( @{ $link->rels || [] } ) { |
|
0
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ( $rel eq $urn ) { |
71
|
0
|
|
|
|
|
|
push @links, $link; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
return \@links; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Net::PMP::CollectionDoc::Links - links from a Net::PMP::CollectionDoc |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $doc = $pmp_client->get_doc( $some_uri ); |
90
|
|
|
|
|
|
|
my $query_links = $doc->get_links('query'); |
91
|
|
|
|
|
|
|
my $query_for_docs = $query_links->rels("urn:collectiondoc:query:docs"); |
92
|
|
|
|
|
|
|
for my $link (@$query_for_docs) { |
93
|
|
|
|
|
|
|
printf("link: %s [%s]\n", $link->title, $link->href); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Net::PMP::CollectionDoc::Links represents the links in a Collection.doc+JSON PMP API response. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 links |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns arrayref of links. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 type |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The flavor of the Links object. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 query_rel_types |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
If B<type> is C<query> then this method can used to return a hashref of rel names |
113
|
|
|
|
|
|
|
to titles. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 rels(I<urn>[, ...I<urn>]) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns arrayref of links that match I<urn>. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Peter Karman, C<< <karman at cpan.org> >> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 BUGS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through |
126
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP>. I will be notified, and then you'll |
127
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 SUPPORT |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
perldoc Net::PMP::CollectionDoc::Links |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
You can also look for information at: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Net-PMP> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * CPAN Ratings |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Net-PMP> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * Search CPAN |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Net-PMP/> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
American Public Media and the Public Media Platform sponsored the development of this module. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright 2013 American Public Media Group |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
See the LICENSE file that accompanies this module. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |