line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
15
|
|
|
15
|
|
118746
|
use warnings; |
|
15
|
|
|
|
|
108
|
|
|
15
|
|
|
|
|
425
|
|
4
|
15
|
|
|
15
|
|
82
|
|
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
455
|
|
5
|
|
|
|
|
|
|
use Mo qw(build is); |
6
|
15
|
|
|
15
|
|
6165
|
use Mo::utils qw(check_isa check_length check_number check_required); |
|
15
|
|
|
|
|
8207
|
|
|
15
|
|
|
|
|
79
|
|
7
|
15
|
|
|
15
|
|
28035
|
|
|
15
|
|
|
|
|
222344
|
|
|
15
|
|
|
|
|
272
|
|
8
|
|
|
|
|
|
|
extends 'Data::Image'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.05; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has commons_name => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has dt_created => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has dt_uploaded => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has license => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has page_id => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
27
|
|
|
27
|
0
|
15923
|
# Check commons_name. |
35
|
|
|
|
|
|
|
check_required($self, 'commons_name'); |
36
|
|
|
|
|
|
|
check_length($self, 'commons_name', 255); |
37
|
27
|
|
|
|
|
117
|
|
38
|
26
|
|
|
|
|
242
|
# Check date created. |
39
|
|
|
|
|
|
|
check_isa($self, 'dt_created', 'DateTime'); |
40
|
|
|
|
|
|
|
|
41
|
26
|
|
|
|
|
390
|
# Check date uploaded. |
42
|
|
|
|
|
|
|
check_isa($self, 'dt_uploaded', 'DateTime'); |
43
|
|
|
|
|
|
|
|
44
|
26
|
|
|
|
|
286
|
# Check page_id. |
45
|
|
|
|
|
|
|
check_number($self, 'page_id'); |
46
|
|
|
|
|
|
|
|
47
|
26
|
|
|
|
|
248
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
26
|
|
|
|
|
225
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Data::Commons::Image - Data object for Wikimedia Commons image. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Data::Commons::Image; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $obj = Data::Commons::Image->new(%params); |
66
|
|
|
|
|
|
|
my $author = $obj->author; |
67
|
|
|
|
|
|
|
my $comment = $obj->comment; |
68
|
|
|
|
|
|
|
my $commons_name = $obj->commons_name; |
69
|
|
|
|
|
|
|
my $dt_created = $obj->dt_created; |
70
|
|
|
|
|
|
|
my $dt_uploaded = $obj->dt_uploaded; |
71
|
|
|
|
|
|
|
my $height = $obj->height; |
72
|
|
|
|
|
|
|
my $id = $obj->id; |
73
|
|
|
|
|
|
|
my $license = $obj->license; |
74
|
|
|
|
|
|
|
my $page_id = $obj->page_id; |
75
|
|
|
|
|
|
|
my $size = $obj->size; |
76
|
|
|
|
|
|
|
my $url = $obj->url; |
77
|
|
|
|
|
|
|
my $url_cb = $obj->url_cb; |
78
|
|
|
|
|
|
|
my $width = $obj->width; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Data object for Wikimedia Commons image. Inherits L<Data::Image> common object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C<new> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $obj = Data::Commons::Image->new(%params); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Constructor. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns instance of object. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * C<author> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Image author. |
99
|
|
|
|
|
|
|
It's optional. |
100
|
|
|
|
|
|
|
Default value is undef. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * C<comment> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Image comment. |
105
|
|
|
|
|
|
|
It's optional. |
106
|
|
|
|
|
|
|
Default value is undef. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * C<commons_name> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Image name in Wikimedia Commons. |
111
|
|
|
|
|
|
|
It's required. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * C<dt_created> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Date and time the image was created. |
116
|
|
|
|
|
|
|
Value must be L<DateTime> object. |
117
|
|
|
|
|
|
|
It's optional. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * C<dt_uploaded> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Date and time the image was uploaded to Wikimedia Commons. |
122
|
|
|
|
|
|
|
Value must be L<DateTime> object. |
123
|
|
|
|
|
|
|
It's optional. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * C<height> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Image height. |
128
|
|
|
|
|
|
|
It's optional. |
129
|
|
|
|
|
|
|
Default value is undef. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * C<id> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Image id. |
134
|
|
|
|
|
|
|
It's optional. |
135
|
|
|
|
|
|
|
Default value is undef. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * C<license> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Image license. |
140
|
|
|
|
|
|
|
It's optional. |
141
|
|
|
|
|
|
|
Default value is undef. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * C<page_id> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Image page id on Wikimedia Commons. |
146
|
|
|
|
|
|
|
It's used for structured data with 'M' prefix. |
147
|
|
|
|
|
|
|
It's optional. |
148
|
|
|
|
|
|
|
Default value is undef. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * C<size> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Image size. |
153
|
|
|
|
|
|
|
It's optional. |
154
|
|
|
|
|
|
|
Default value is undef. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * C<url> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
URL of image. |
159
|
|
|
|
|
|
|
It's optional. |
160
|
|
|
|
|
|
|
Default value is undef. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * C<url_cb> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
URL callback. To get URL from code. |
165
|
|
|
|
|
|
|
It's optional. |
166
|
|
|
|
|
|
|
Default value is undef. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * C<width> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Image width. |
171
|
|
|
|
|
|
|
It's optional. |
172
|
|
|
|
|
|
|
Default value is undef. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=back |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 C<author> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $author = $obj->author; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Get image author. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Returns string. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 C<comment> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
my $comment = $obj->comment; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Get image comment. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Returns string. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 C<commons_name> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $commons_name = $obj->commons_name; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Get image name in Wikimedia Commons. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Returns string. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 C<dt_created> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
my $dt_created = $obj->dt_created; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Get date and time the image was created. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Returns L<DateTime> object. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 C<dt_uploaded> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
my $dt_uploaded = $obj->dt_uploaded; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Get date and time the image was uploaded to Wikimedia Commons. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Returns L<DateTime> object. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head2 C<height> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $height = $obj->height; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Get image height. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Returns number. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 C<id> |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
my $id = $obj->id; |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Get image id. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Returns number. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 C<license> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
my $license = $obj->license; |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Get image license. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Returns string. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 C<page_id> |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
my $page_id = $obj->page_id; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Get image page id. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Returns number. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 C<size> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
my $size = $obj->size; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Get image size. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Returns number. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 C<url> |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
my $url = $obj->url; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Get URL of image. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Returns string. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head2 C<url_cb> |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my $url_cb = $obj->url_cb; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Get URL callback. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Returns code. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 C<width> |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
my $width = $obj->width; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Get image width. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Returns number. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 EXAMPLE |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=for comment filename=create_and_print_image.pl |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
use strict; |
285
|
|
|
|
|
|
|
use warnings; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
use Data::Commons::Image; |
288
|
|
|
|
|
|
|
use DateTime; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
my $obj = Data::Commons::Image->new( |
291
|
|
|
|
|
|
|
'author' => 'Zuzana Zonova', |
292
|
|
|
|
|
|
|
'comment' => 'Michal from Czechia', |
293
|
|
|
|
|
|
|
'commons_name' => 'Michal_from_Czechia.jpg', |
294
|
|
|
|
|
|
|
'dt_created' => DateTime->new( |
295
|
|
|
|
|
|
|
'day' => 1, |
296
|
|
|
|
|
|
|
'month' => 1, |
297
|
|
|
|
|
|
|
'year' => 2022, |
298
|
|
|
|
|
|
|
), |
299
|
|
|
|
|
|
|
'dt_uploaded' => DateTime->new( |
300
|
|
|
|
|
|
|
'day' => 14, |
301
|
|
|
|
|
|
|
'month' => 7, |
302
|
|
|
|
|
|
|
'year' => 2022, |
303
|
|
|
|
|
|
|
), |
304
|
|
|
|
|
|
|
'height' => 2730, |
305
|
|
|
|
|
|
|
'license' => 'cc-by-sa-4.0', |
306
|
|
|
|
|
|
|
'page_id' => '95648152', |
307
|
|
|
|
|
|
|
'size' => 1040304, |
308
|
|
|
|
|
|
|
'url' => 'https://upload.wikimedia.org/wikipedia/commons/a/a4/Michal_from_Czechia.jpg', |
309
|
|
|
|
|
|
|
'width' => 4096, |
310
|
|
|
|
|
|
|
); |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# Print out. |
313
|
|
|
|
|
|
|
print 'Author: '.$obj->author."\n"; |
314
|
|
|
|
|
|
|
print 'Comment: '.$obj->comment."\n"; |
315
|
|
|
|
|
|
|
print 'Wikimedia Commons name: '.$obj->commons_name."\n"; |
316
|
|
|
|
|
|
|
print 'Height: '.$obj->height."\n"; |
317
|
|
|
|
|
|
|
print 'Size: '.$obj->size."\n"; |
318
|
|
|
|
|
|
|
print 'URL: '.$obj->url."\n"; |
319
|
|
|
|
|
|
|
print 'Width: '.$obj->width."\n"; |
320
|
|
|
|
|
|
|
print 'License: '.$obj->license."\n"; |
321
|
|
|
|
|
|
|
print 'Page id: '.$obj->page_id."\n"; |
322
|
|
|
|
|
|
|
print 'Date and time the photo was created: '.$obj->dt_created."\n"; |
323
|
|
|
|
|
|
|
print 'Date and time the photo was uploaded: '.$obj->dt_uploaded."\n"; |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
# Output: |
326
|
|
|
|
|
|
|
# Author: Zuzana Zonova |
327
|
|
|
|
|
|
|
# Comment: Michal from Czechia |
328
|
|
|
|
|
|
|
# Wikimedia Commons name: Michal_from_Czechia.jpg |
329
|
|
|
|
|
|
|
# Height: 2730 |
330
|
|
|
|
|
|
|
# Size: 1040304 |
331
|
|
|
|
|
|
|
# URL: https://upload.wikimedia.org/wikipedia/commons/a/a4/Michal_from_Czechia.jpg |
332
|
|
|
|
|
|
|
# Width: 4096 |
333
|
|
|
|
|
|
|
# License: cc-by-sa-4.0 |
334
|
|
|
|
|
|
|
# Page id: 95648152 |
335
|
|
|
|
|
|
|
# Date and time the photo was created: 2022-01-01T00:00:00 |
336
|
|
|
|
|
|
|
# Date and time the photo was uploaded: 2022-07-14T00:00:00 |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
L<Data::Image>, |
341
|
|
|
|
|
|
|
L<Mo>, |
342
|
|
|
|
|
|
|
L<Mo::utils>. |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=head1 REPOSITORY |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-Commons-Image> |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=head1 AUTHOR |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
L<http://skim.cz> |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
© 2022 Michal Josef Špaček |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
BSD 2-Clause License |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=head1 VERSION |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
0.05 |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |