line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Print::Sitelink; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
917993
|
use base qw(Exporter); |
|
7
|
|
|
|
|
51
|
|
|
7
|
|
|
|
|
715
|
|
4
|
7
|
|
|
7
|
|
46
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
174
|
|
5
|
7
|
|
|
7
|
|
46
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
228
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
999
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
23669
|
|
|
7
|
|
|
|
|
280
|
|
8
|
7
|
|
|
7
|
|
141
|
use Readonly; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
273
|
|
9
|
7
|
|
|
7
|
|
3188
|
use Wikibase::Datatype::Print::Value::Item; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
1580
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(print); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.12; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub print { |
16
|
4
|
|
|
4
|
1
|
1386
|
my ($obj, $opts_hr) = @_; |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
27
|
if (! $obj->isa('Wikibase::Datatype::Sitelink')) { |
19
|
1
|
|
|
|
|
5
|
err "Object isn't 'Wikibase::Datatype::Sitelink'."; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
10
|
my $ret = ''; |
23
|
3
|
50
|
|
|
|
22
|
if (defined $obj->title) { |
24
|
3
|
|
|
|
|
37
|
$ret .= $obj->title; |
25
|
|
|
|
|
|
|
} |
26
|
3
|
50
|
|
|
|
26
|
if (defined $obj->site) { |
27
|
3
|
|
|
|
|
29
|
$ret .= ' ('.$obj->site.')'; |
28
|
|
|
|
|
|
|
} |
29
|
3
|
100
|
|
|
|
23
|
if (@{$obj->badges}) { |
|
3
|
|
|
|
|
13
|
|
30
|
1
|
|
|
|
|
18
|
my @print = map { Wikibase::Datatype::Print::Value::Item::print($_, $opts_hr) } @{$obj->badges}; |
|
2
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
3
|
|
31
|
1
|
|
|
|
|
6
|
$ret .= ' ['.(join ' ', @print).']'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
30
|
return $ret; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=encoding utf8 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Wikibase::Datatype::Print::Sitelink - Wikibase sitelink pretty print helpers. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Sitelink qw(print); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SUBROUTINES |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 C<print> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Construct pretty print output for L<Wikibase::Datatype::Sitelink> |
62
|
|
|
|
|
|
|
object. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns string. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 ERRORS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
print(): |
69
|
|
|
|
|
|
|
Object isn't 'Wikibase::Datatype::Sitelink'. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 EXAMPLE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=for comment filename=create_and_print_sitelink.pl |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use strict; |
76
|
|
|
|
|
|
|
use warnings; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
79
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Sitelink; |
80
|
|
|
|
|
|
|
use Wikibase::Datatype::Sitelink; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Object. |
83
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Sitelink->new( |
84
|
|
|
|
|
|
|
'badges' => [ |
85
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Item->new( |
86
|
|
|
|
|
|
|
'value' => 'Q123', |
87
|
|
|
|
|
|
|
), |
88
|
|
|
|
|
|
|
], |
89
|
|
|
|
|
|
|
'site' => 'cswiki', |
90
|
|
|
|
|
|
|
'title' => decode_utf8('Hlavní strana'), |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Print. |
94
|
|
|
|
|
|
|
print encode_utf8(Wikibase::Datatype::Print::Sitelink::print($obj))."\n"; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Output: |
97
|
|
|
|
|
|
|
# Hlavní strana (cswiki) [Q123] |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<Error::Pure>, |
102
|
|
|
|
|
|
|
L<Exporter>, |
103
|
|
|
|
|
|
|
L<Readonly>, |
104
|
|
|
|
|
|
|
L<Wikibase::Datatype::Print::Value::Item>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Sitelink> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Wikibase sitelink datatype. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 REPOSITORY |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<http://skim.cz> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
BSD 2-Clause License |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 VERSION |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
0.12 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |