line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Sitelink; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
654587
|
use strict; |
|
10
|
|
|
|
|
91
|
|
|
10
|
|
|
|
|
278
|
|
4
|
10
|
|
|
10
|
|
58
|
use warnings; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
276
|
|
5
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
2519
|
use Mo qw(build default is); |
|
10
|
|
|
|
|
3002
|
|
|
10
|
|
|
|
|
54
|
|
7
|
10
|
|
|
10
|
|
16813
|
use Mo::utils qw(check_array_object check_required); |
|
10
|
|
|
|
|
67637
|
|
|
10
|
|
|
|
|
737
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.31; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has badges => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
default => [], |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has site => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has title => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub BUILD { |
25
|
12
|
|
|
12
|
0
|
10484
|
my $self = shift; |
26
|
|
|
|
|
|
|
|
27
|
12
|
|
|
|
|
75
|
check_required($self, 'site'); |
28
|
11
|
|
|
|
|
122
|
check_required($self, 'title'); |
29
|
|
|
|
|
|
|
|
30
|
10
|
|
|
|
|
86
|
check_array_object($self, 'badges', 'Wikibase::Datatype::Value::Item', 'Badge'); |
31
|
|
|
|
|
|
|
|
32
|
8
|
|
|
|
|
141
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding utf8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Wikibase::Datatype::Sitelink - Wikibase sitelink datatype. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Wikibase::Datatype::Sitelink; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sitelink->new(%params); |
52
|
|
|
|
|
|
|
my $badges_ar = $obj->badges; |
53
|
|
|
|
|
|
|
my $site = $obj->site; |
54
|
|
|
|
|
|
|
my $title = $obj->title; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This datatype is sitelink class for representing link to wikimedia projects |
59
|
|
|
|
|
|
|
(e.g. Czech Wikipedia). |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 C<new> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sitelink->new(%params); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Constructor. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns instance of object. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * C<badges> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Badges. |
76
|
|
|
|
|
|
|
Default value is []. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * C<site> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Site shortcut (e.g. cswiki). |
81
|
|
|
|
|
|
|
Parameter is required. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * C<title> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Page title (e.g. 'Main Page'). |
86
|
|
|
|
|
|
|
Parameter is required. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 C<badges> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $badges_ar = $obj->badges; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Get badges (Badge is link to item - regexp /^Q\d+$/). |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns reference to array with strings. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 C<site> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $site = $obj->site; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Get site. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns string. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 C<title> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $title = $obj->title; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Get title. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns string. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 ERRORS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
new(): |
117
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
118
|
|
|
|
|
|
|
Parameter 'site' is required. |
119
|
|
|
|
|
|
|
Parameter 'title' is required. |
120
|
|
|
|
|
|
|
From Mo::utils::check_array_object(): |
121
|
|
|
|
|
|
|
Badge isn't 'Wikibase::Datatype::Value::Item' object. |
122
|
|
|
|
|
|
|
Parameter 'badges' must be a array. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 EXAMPLE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=for comment filename=create_and_print_sitelink.pl |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use strict; |
129
|
|
|
|
|
|
|
use warnings; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
132
|
|
|
|
|
|
|
use Wikibase::Datatype::Sitelink; |
133
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Object. |
136
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sitelink->new( |
137
|
|
|
|
|
|
|
'badges' => [ |
138
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Item->new( |
139
|
|
|
|
|
|
|
'value' => 'Q123', |
140
|
|
|
|
|
|
|
), |
141
|
|
|
|
|
|
|
], |
142
|
|
|
|
|
|
|
'site' => 'cswiki', |
143
|
|
|
|
|
|
|
'title' => decode_utf8('Hlavní strana'), |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Get badges. |
147
|
|
|
|
|
|
|
my $badges_ar = [map { $_->value } @{$obj->badges}]; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# Get site. |
150
|
|
|
|
|
|
|
my $site = $obj->site; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Get title. |
153
|
|
|
|
|
|
|
my $title = $obj->title; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Print out. |
156
|
|
|
|
|
|
|
print 'Badges: '.(join ', ', @{$badges_ar})."\n"; |
157
|
|
|
|
|
|
|
print "Site: $site\n"; |
158
|
|
|
|
|
|
|
print 'Title: '.encode_utf8($title)."\n"; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# Output: |
161
|
|
|
|
|
|
|
# Badges: Q123 |
162
|
|
|
|
|
|
|
# Site: cswiki |
163
|
|
|
|
|
|
|
# Title: Hlavní strana |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<Mo>, |
168
|
|
|
|
|
|
|
L<Mo::utils>. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 SEE ALSO |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=over |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item L<Wikibase::Datatype> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Wikibase datatypes. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 REPOSITORY |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 AUTHOR |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L<http://skim.cz> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
BSD 2-Clause License |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 VERSION |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
0.31 |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |