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