line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::MediainfoSnak; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
1258345
|
use strict; |
|
20
|
|
|
|
|
159
|
|
|
20
|
|
|
|
|
631
|
|
4
|
20
|
|
|
20
|
|
131
|
use warnings; |
|
20
|
|
|
|
|
43
|
|
|
20
|
|
|
|
|
652
|
|
5
|
|
|
|
|
|
|
|
6
|
20
|
|
|
20
|
|
6332
|
use Error::Pure qw(err); |
|
20
|
|
|
|
|
141826
|
|
|
20
|
|
|
|
|
562
|
|
7
|
20
|
|
|
20
|
|
9610
|
use List::MoreUtils qw(none); |
|
20
|
|
|
|
|
195551
|
|
|
20
|
|
|
|
|
127
|
|
8
|
20
|
|
|
20
|
|
25435
|
use Mo qw(build is); |
|
20
|
|
|
|
|
7104
|
|
|
20
|
|
|
|
|
109
|
|
9
|
20
|
|
|
20
|
|
27971
|
use Mo::utils qw(check_isa check_required); |
|
20
|
|
|
|
|
20581
|
|
|
20
|
|
|
|
|
522
|
|
10
|
20
|
|
|
20
|
|
1376
|
use Readonly; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
827
|
|
11
|
20
|
|
|
20
|
|
9109
|
use Wikibase::Datatype::Utils qw(check_property); |
|
20
|
|
|
|
|
71
|
|
|
20
|
|
|
|
|
472
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Readonly::Array our @SNAK_TYPES => qw( |
14
|
|
|
|
|
|
|
novalue |
15
|
|
|
|
|
|
|
somevalue |
16
|
|
|
|
|
|
|
value |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = 0.29; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has datavalue => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has property => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has snaktype => ( |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub BUILD { |
34
|
26
|
|
|
26
|
0
|
6901
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Check snak type. |
37
|
26
|
100
|
|
|
|
135
|
if (defined $self->{'snaktype'}) { |
38
|
5
|
100
|
|
9
|
|
37
|
if (none { $self->{'snaktype'} eq $_ } @SNAK_TYPES) { |
|
9
|
|
|
|
|
149
|
|
39
|
1
|
|
|
|
|
5
|
err "Parameter 'snaktype' = '$self->{'snaktype'}' isn't supported."; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} else { |
42
|
21
|
|
|
|
|
61
|
$self->{'snaktype'} = 'value'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Requirements. |
46
|
25
|
100
|
|
|
|
101
|
if ($self->{'snaktype'} eq 'value') { |
47
|
21
|
|
|
|
|
89
|
check_required($self, 'datavalue'); |
48
|
|
|
|
|
|
|
} |
49
|
24
|
|
|
|
|
195
|
check_required($self, 'property'); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check data value. |
52
|
23
|
100
|
|
|
|
178
|
if ($self->{'snaktype'} eq 'value') { |
53
|
19
|
|
|
|
|
64
|
check_isa($self, 'datavalue', 'Wikibase::Datatype::Value'); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Check property. |
57
|
22
|
|
|
|
|
513
|
check_property($self, 'property'); |
58
|
|
|
|
|
|
|
|
59
|
21
|
|
|
|
|
49
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=encoding utf8 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Wikibase::Datatype::MediainfoSnak - Wikibase mediainfo snak datatype. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use Wikibase::Datatype::MediainfoSnak; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::MediainfoSnak->new(%params); |
79
|
|
|
|
|
|
|
my $datavalue = $obj->datavalue; |
80
|
|
|
|
|
|
|
my $property = $obj->property; |
81
|
|
|
|
|
|
|
my $snaktype = $obj->snaktype; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This datatype is snak class for representing relation between property and value. |
86
|
|
|
|
|
|
|
This datatype is used in statements in Commons structured data instead of snak |
87
|
|
|
|
|
|
|
datatype. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C<new> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::MediainfoSnak->new(%params); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Constructor. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Retruns instance of object. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 8 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * C<datavalue> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Value of data. |
104
|
|
|
|
|
|
|
Parameter is required. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * C<property> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Property name (like /^P\d+$/). |
109
|
|
|
|
|
|
|
Parameter is required. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * C<snaktype> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Snak type. |
114
|
|
|
|
|
|
|
Parameter is string with these possible values: novalue somevalue value |
115
|
|
|
|
|
|
|
Parameter is optional. |
116
|
|
|
|
|
|
|
Default value is 'value'. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 C<datavalue> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $datavalue = $obj->datavalue; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Get data value. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns instance of Wikibase::Datatype::Value. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 C<property> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $property = $obj->property; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Get property name. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns string. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 C<snaktype> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $snaktype = $obj->snaktype; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Get snak type. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Returns string. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ERRORS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
new(): |
147
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
148
|
|
|
|
|
|
|
Parameter 'datavalue' is required. |
149
|
|
|
|
|
|
|
Parameter 'property' is required. |
150
|
|
|
|
|
|
|
From Mo::utils::check_isa(): |
151
|
|
|
|
|
|
|
Parameter 'datavalue' must be a 'Wikibase::Datatype::Value' object. |
152
|
|
|
|
|
|
|
From Wikibase::Datatype::Utils::check_property(): |
153
|
|
|
|
|
|
|
Parameter 'property' must begin with 'P' and number after it. |
154
|
|
|
|
|
|
|
Parameter 'snaktype' = '%s' isn't supported. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 EXAMPLE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=for comment filename=create_and_print_mediainfosnak.pl |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
use strict; |
161
|
|
|
|
|
|
|
use warnings; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
use Wikibase::Datatype::MediainfoSnak; |
164
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# Object. |
167
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::MediainfoSnak->new( |
168
|
|
|
|
|
|
|
'datavalue' => Wikibase::Datatype::Value::Item->new( |
169
|
|
|
|
|
|
|
'value' => 'Q14946043', |
170
|
|
|
|
|
|
|
), |
171
|
|
|
|
|
|
|
'property' => 'P275', |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Get value. |
175
|
|
|
|
|
|
|
my $datavalue = $obj->datavalue->value; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Get property. |
178
|
|
|
|
|
|
|
my $property = $obj->property; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# Get snak type. |
181
|
|
|
|
|
|
|
my $snaktype = $obj->snaktype; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Print out. |
184
|
|
|
|
|
|
|
print "Property: $property\n"; |
185
|
|
|
|
|
|
|
print "Value: $datavalue\n"; |
186
|
|
|
|
|
|
|
print "Snak type: $snaktype\n"; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# Output: |
189
|
|
|
|
|
|
|
# Property: P275 |
190
|
|
|
|
|
|
|
# Value: Q14946043 |
191
|
|
|
|
|
|
|
# Snak type: value |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<Error::Pure>, |
196
|
|
|
|
|
|
|
L<List::MoreUtils>, |
197
|
|
|
|
|
|
|
L<Mo>, |
198
|
|
|
|
|
|
|
L<Mo::utils>, |
199
|
|
|
|
|
|
|
L<Readonly>, |
200
|
|
|
|
|
|
|
L<Wikibase::Datatype::Utils>. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SEE ALSO |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=over |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item L<Wikibase::Datatype> |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Wikibase datatypes. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Snak> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Wikibase snak datatype. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=back |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 REPOSITORY |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
L<http://skim.cz> |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
BSD 2-Clause License |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 VERSION |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
0.29 |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=cut |