| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::NOS::Open::Resource 0.101; # -*- cperl; cperl-indent-level: 4 -*- |
|
2
|
5
|
|
|
5
|
|
2386
|
use strict; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
124
|
|
|
3
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
108
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
22
|
use utf8; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
54
|
|
|
6
|
5
|
|
|
5
|
|
142
|
use 5.014000; |
|
|
5
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
23
|
use Moose qw/has/; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
49
|
|
|
9
|
5
|
|
|
5
|
|
22275
|
use Moose::Util::TypeConstraints qw/enum/; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
43
|
|
|
10
|
5
|
|
|
5
|
|
3886
|
use MooseX::Types::Moose qw/Undef/; |
|
|
5
|
|
|
|
|
234578
|
|
|
|
5
|
|
|
|
|
76
|
|
|
11
|
5
|
|
|
5
|
|
22491
|
use namespace::autoclean '-also' => qr/^__/sxm; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
43
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
|
2957
|
use WWW::NOS::Open::TypeDef qw(NOSDateTime NOSURI); |
|
|
5
|
|
|
|
|
26
|
|
|
|
5
|
|
|
|
|
40
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
10584
|
use Readonly; |
|
|
5
|
|
|
|
|
14079
|
|
|
|
5
|
|
|
|
|
1372
|
|
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $UNDER => q{_}; |
|
17
|
|
|
|
|
|
|
Readonly::Scalar my $GETTER => q{get}; |
|
18
|
|
|
|
|
|
|
Readonly::Scalar my $THUMB => q{thumbnail}; |
|
19
|
|
|
|
|
|
|
Readonly::Array my @THUMBS => qw(xs s m); |
|
20
|
|
|
|
|
|
|
Readonly::Array my @RESOURCE_TYPES => qw(article video audio); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has '_id' => ( |
|
23
|
|
|
|
|
|
|
'is' => 'ro', |
|
24
|
|
|
|
|
|
|
'isa' => 'Int', |
|
25
|
|
|
|
|
|
|
'reader' => 'get_id', |
|
26
|
|
|
|
|
|
|
'init_arg' => 'id', |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my @types = qw(type); |
|
30
|
|
|
|
|
|
|
while ( my $type = shift @types ) { |
|
31
|
|
|
|
|
|
|
has $UNDER |
|
32
|
|
|
|
|
|
|
. $type => ( |
|
33
|
|
|
|
|
|
|
'is' => 'ro', |
|
34
|
|
|
|
|
|
|
'isa' => enum( [@RESOURCE_TYPES] ), |
|
35
|
|
|
|
|
|
|
'reader' => $GETTER . $UNDER . $type, |
|
36
|
|
|
|
|
|
|
'init_arg' => $type, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @strings = qw(title description); |
|
41
|
|
|
|
|
|
|
while ( my $string = shift @strings ) { |
|
42
|
|
|
|
|
|
|
has $UNDER |
|
43
|
|
|
|
|
|
|
. $string => ( |
|
44
|
|
|
|
|
|
|
'is' => 'ro', |
|
45
|
|
|
|
|
|
|
'isa' => 'Str', |
|
46
|
|
|
|
|
|
|
'reader' => $GETTER . $UNDER . $string, |
|
47
|
|
|
|
|
|
|
'init_arg' => $string, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @dates = qw(published last_update); |
|
52
|
|
|
|
|
|
|
while ( my $date = shift @dates ) { |
|
53
|
|
|
|
|
|
|
has $UNDER |
|
54
|
|
|
|
|
|
|
. $date => ( |
|
55
|
|
|
|
|
|
|
'is' => 'ro', |
|
56
|
|
|
|
|
|
|
'isa' => 'WWW::NOS::Open::TypeDef::NOSDateTime', |
|
57
|
|
|
|
|
|
|
'coerce' => 1, |
|
58
|
|
|
|
|
|
|
'reader' => $GETTER . $UNDER . $date, |
|
59
|
|
|
|
|
|
|
'init_arg' => $date, |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my @uris = map { $THUMB . $UNDER . $_ } @THUMBS; |
|
64
|
|
|
|
|
|
|
push @uris, q{link}; |
|
65
|
|
|
|
|
|
|
while ( my $uri = shift @uris ) { |
|
66
|
|
|
|
|
|
|
has $UNDER |
|
67
|
|
|
|
|
|
|
. $uri => ( |
|
68
|
|
|
|
|
|
|
'is' => 'ro', |
|
69
|
|
|
|
|
|
|
'isa' => 'WWW::NOS::Open::TypeDef::NOSURI | Undef', |
|
70
|
|
|
|
|
|
|
'coerce' => 1, |
|
71
|
|
|
|
|
|
|
'reader' => $GETTER . $UNDER . $uri, |
|
72
|
|
|
|
|
|
|
'init_arg' => $uri, |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has '_keywords' => ( |
|
77
|
|
|
|
|
|
|
'traits' => ['Array'], |
|
78
|
|
|
|
|
|
|
'is' => 'ro', |
|
79
|
|
|
|
|
|
|
'isa' => 'ArrayRef[Str]', |
|
80
|
|
|
|
|
|
|
'default' => sub { [] }, |
|
81
|
|
|
|
|
|
|
'reader' => 'get_keywords', |
|
82
|
|
|
|
|
|
|
'init_arg' => 'keywords', |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
5
|
|
|
5
|
|
37
|
no Moose; |
|
|
5
|
|
|
|
|
16
|
|
|
|
5
|
|
|
|
|
55
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=encoding utf8 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=for stopwords multiline DateTime URI Readonly Ipenburg MERCHANTABILITY |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
WWW::NOS::Open::Resource - client side resource in the Open NOS REST API. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 VERSION |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This document describes WWW::NOS::Open::Resource version 0.101. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
use Moose qw/extends/; |
|
108
|
|
|
|
|
|
|
extends 'WWW::NOS::Open::Resource'; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This class represents a resources as returned in the latest ten articles list. |
|
113
|
|
|
|
|
|
|
It is the base class for the |
|
114
|
|
|
|
|
|
|
L<WWW::NOS::Open::Article|WWW::NOS::Open::Article> and |
|
115
|
|
|
|
|
|
|
L<WWW::NOS::Open::MediaResource|WWW::NOS::Open::MediaResource> classes. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<new> |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Create a new resource. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item id: The unique identifier of the resource as an integer. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item type: The type of the resource, one of "article", "video" or "article". |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item title: The title of the resource as string. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item description: The multiline description of the resource as string. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item published: The date and time the resource was first published as |
|
134
|
|
|
|
|
|
|
L<DateTime|DateTime> object. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item last_update: The date and time the resource was updated for the last |
|
137
|
|
|
|
|
|
|
time as L<DateTime|DateTime> object. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item thumbnail_xs: The location of an extra small thumbnail for the resource |
|
140
|
|
|
|
|
|
|
as L<URI|URI> object. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item thumbnail_s: The location of a small thumbnail for the resource as |
|
143
|
|
|
|
|
|
|
L<URI|URI> object. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item thumbnail_m: The location of a medium sized thumbnail for the resource |
|
146
|
|
|
|
|
|
|
as L<URI|URI> object. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item link: The link to the complete resource as L<URI|URI> object. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item keywords: A reference to a list of keywords for the resource. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 C<get_id> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Returns the id of the resource as integer. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 C<get_title> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Returns the title of the resource as string. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 C<get_description> |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Returns the multiline description of the resource as a string. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 C<get_published> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns the first publishing date and time of the resource as a |
|
169
|
|
|
|
|
|
|
L<DateTime|DateTime> object. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 C<get_last_update> |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns the date and time of the last update for the resource as a |
|
174
|
|
|
|
|
|
|
L<DateTime|DateTime> object. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 C<get_thumbnail_xs> |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Returns the location of the extra small thumbnail for the resource as an |
|
179
|
|
|
|
|
|
|
L<URI|URI> object. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 C<get_thumbnail_s> |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returns the location of the small thumbnail for the resource as an L<URI|URI> |
|
184
|
|
|
|
|
|
|
object. |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 C<get_thumbnail_m> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Returns the location of the medium sized thumbnail for the resource as an |
|
189
|
|
|
|
|
|
|
L<URI|URI> object. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 C<get_link> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns the location of the complete resource as an L<URI|URI> object. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 C<get_keywords> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns the list of keywords for the article as a reference to an array of |
|
198
|
|
|
|
|
|
|
strings. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=over 4 |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints> |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item * L<Moose|Moose> |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * L<Readonly|Readonly> |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item * L<WWW::NOS::Open::TypeDef|WWW::NOS::Open::TypeDef> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * L<namespace::autoclean|namespace::autoclean> |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Please report any bugs or feature requests at |
|
225
|
|
|
|
|
|
|
L<RT for rt.cpan.org|https://rt.cpan.org/Dist/Display.html?Queue=WWW-NOS-Open>. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 AUTHOR |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Roland van Ipenburg, E<lt>ipenburg@xs4all.nlE<gt> |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Copyright 2012 by Roland van Ipenburg |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
236
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.14.0 or, |
|
237
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
242
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
243
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
244
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
245
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
246
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
247
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
248
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
249
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
252
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
253
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE |
|
254
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
255
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
256
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
257
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
258
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
259
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
260
|
|
|
|
|
|
|
SUCH DAMAGES. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |