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