line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::PMP::CollectionDoc::Link; |
2
|
3
|
|
|
3
|
|
19
|
use Moose; |
|
3
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
16
|
|
3
|
3
|
|
|
3
|
|
11293
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
153
|
|
4
|
3
|
|
|
3
|
|
16
|
use Data::Dump qw( dump ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
105
|
|
5
|
3
|
|
|
3
|
|
934
|
use URI::Template; |
|
3
|
|
|
|
|
11542
|
|
|
3
|
|
|
|
|
97
|
|
6
|
3
|
|
|
3
|
|
25
|
use Net::PMP::TypeConstraints; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1585
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'hints' => ( is => 'rw', isa => 'HashRef' ); |
11
|
|
|
|
|
|
|
has 'template' => ( is => 'rw', isa => 'Str' ); |
12
|
|
|
|
|
|
|
has 'vars' => ( is => 'rw', isa => 'HashRef' ); |
13
|
|
|
|
|
|
|
has 'rels' => ( is => 'rw', isa => 'ArrayRef', ); |
14
|
|
|
|
|
|
|
has 'title' => ( is => 'rw', isa => 'Str' ); |
15
|
|
|
|
|
|
|
has 'href' => ( is => 'rw', isa => 'Net::PMP::Type::Href', coerce => 1, ); |
16
|
|
|
|
|
|
|
has 'method' => ( is => 'rw', isa => 'Str' ); |
17
|
|
|
|
|
|
|
has 'type' => ( is => 'rw', isa => 'Str' ); |
18
|
|
|
|
|
|
|
has 'pagenum' => ( is => 'rw', isa => 'Int' ); |
19
|
|
|
|
|
|
|
has 'totalpages' => ( is => 'rw', isa => 'Int' ); |
20
|
|
|
|
|
|
|
has 'totalitems' => ( is => 'rw', isa => 'Int' ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# these for MediaEnclosure |
23
|
|
|
|
|
|
|
has 'media_meta' => ( is => 'rw', isa => 'HashRef' ); |
24
|
|
|
|
|
|
|
has 'crop' => ( is => 'rw', isa => 'Str' ); |
25
|
|
|
|
|
|
|
has 'format' => ( is => 'rw', isa => 'Str' ); |
26
|
|
|
|
|
|
|
has 'codec' => ( is => 'rw', isa => 'Str' ); |
27
|
|
|
|
|
|
|
has 'duration' => ( is => 'rw', isa => 'Str' ); |
28
|
|
|
|
|
|
|
has 'width' => ( is => 'rw', isa => 'Str' ); |
29
|
|
|
|
|
|
|
has 'height' => ( is => 'rw', isa => 'Str' ); |
30
|
|
|
|
|
|
|
has 'resolution' => ( is => 'rw', isa => 'Str' ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub options { |
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
34
|
0
|
0
|
0
|
|
|
|
if ( $self->vars and $self->template ) { |
35
|
0
|
|
|
|
|
|
return $self->vars; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
0
|
|
|
|
|
|
croak "Link is not a properly defined href template"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_uri { |
43
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
44
|
0
|
0
|
|
|
|
|
my $options = shift or croak "options required"; |
45
|
0
|
0
|
|
|
|
|
if ( !$self->template ) { |
46
|
0
|
|
|
|
|
|
croak "No template defined in Link"; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
my $tmpl = URI::Template->new( $self->template ); |
49
|
0
|
|
|
|
|
|
return $tmpl->process( $self->_mangle_options($options) ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub as_hash { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
return { %{$self} }; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _coerce_opt { |
58
|
0
|
|
|
0
|
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $opt = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# may be of the form: |
62
|
|
|
|
|
|
|
# ['AND' => ['foo', 'bar']] or |
63
|
|
|
|
|
|
|
# ['foo','bar'] or |
64
|
|
|
|
|
|
|
# ['OR' => ['foo','bar']] |
65
|
0
|
0
|
|
|
|
|
if ( $opt->[0] eq 'AND' ) { |
|
|
0
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return join( ',', @{ $opt->[1] } ); |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
elsif ( $opt->[0] eq 'OR' ) { |
69
|
0
|
|
|
|
|
|
return join( ';', @{ $opt->[1] } ); |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
0
|
|
|
|
|
|
return join( ',', @$opt ); # assume AND |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _mangle_options { |
77
|
0
|
|
|
0
|
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
my $opts = shift; |
79
|
0
|
|
|
|
|
|
my %mangled; |
80
|
0
|
|
|
|
|
|
for my $key ( keys %$opts ) { |
81
|
0
|
0
|
|
|
|
|
if ( ref $opts->{$key} eq 'ARRAY' ) { |
|
|
0
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$mangled{$key} = $self->_coerce_opt( $opts->{$key} ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
elsif ( ref $opts->{$key} ) { |
85
|
0
|
|
|
|
|
|
croak "unsupported reference for option '$key'"; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
0
|
|
|
|
|
|
$mangled{$key} = $opts->{$key}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
return \%mangled; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Net::PMP::CollectionDoc::Link - link from a Net::PMP::CollectionDoc::Links object |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $doc = $pmp_client->get_doc( $some_uri ); |
107
|
|
|
|
|
|
|
my $query_links = $doc->get_links('query'); |
108
|
|
|
|
|
|
|
my $query_for_docs = $query_links->rels("urn:collectiondoc:query:docs"); |
109
|
|
|
|
|
|
|
for my $link (@$query_for_docs) { |
110
|
|
|
|
|
|
|
printf("link: %s [%s]\n", $link->title, $link->href); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 DESCRIPTION |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Net::PMP::CollectionDoc::Link represents a link in a Collection.doc+JSON PMP API response. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 METHODS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 hints |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 href |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 title |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 rels |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 vars |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 template |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 method |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 type |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 options |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 as_uri(I<options>) |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Applies I<options> hashref against the template() value and returns a URI object. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 as_hash |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns object as Perl hashref. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Peter Karman, C<< <karman at cpan.org> >> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 BUGS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through |
152
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP>. I will be notified, and then you'll |
153
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SUPPORT |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
perldoc Net::PMP::CollectionDoc::Link |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You can also look for information at: |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 4 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Net-PMP> |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * CPAN Ratings |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Net-PMP> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * Search CPAN |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Net-PMP/> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
American Public Media and the Public Media Platform sponsored the development of this module. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Copyright 2013 American Public Media Group |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
See the LICENSE file that accompanies this module. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |