line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Print::Sitelink; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
905461
|
use base qw(Exporter); |
|
7
|
|
|
|
|
48
|
|
|
7
|
|
|
|
|
670
|
|
4
|
7
|
|
|
7
|
|
53
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
141
|
|
5
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
263
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
959
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
22568
|
|
|
7
|
|
|
|
|
232
|
|
8
|
7
|
|
|
7
|
|
186
|
use Readonly; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
320
|
|
9
|
7
|
|
|
7
|
|
3157
|
use Wikibase::Datatype::Print::Value::Item; |
|
7
|
|
|
|
|
27
|
|
|
7
|
|
|
|
|
1638
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(print); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.09; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub print { |
16
|
4
|
|
|
4
|
1
|
1389
|
my ($obj, $opts_hr) = @_; |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
31
|
if (! $obj->isa('Wikibase::Datatype::Sitelink')) { |
19
|
1
|
|
|
|
|
5
|
err "Object isn't 'Wikibase::Datatype::Sitelink'."; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
9
|
my $ret = ''; |
23
|
3
|
50
|
|
|
|
13
|
if (defined $obj->title) { |
24
|
3
|
|
|
|
|
32
|
$ret .= $obj->title; |
25
|
|
|
|
|
|
|
} |
26
|
3
|
50
|
|
|
|
27
|
if (defined $obj->site) { |
27
|
3
|
|
|
|
|
32
|
$ret .= ' ('.$obj->site.')'; |
28
|
|
|
|
|
|
|
} |
29
|
3
|
100
|
|
|
|
20
|
if (@{$obj->badges}) { |
|
3
|
|
|
|
|
11
|
|
30
|
1
|
|
|
|
|
14
|
my @print = map { Wikibase::Datatype::Print::Value::Item::print($_, $opts_hr) } @{$obj->badges}; |
|
2
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
3
|
|
31
|
1
|
|
|
|
|
4
|
$ret .= ' ['.(join ' ', @print).']'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
32
|
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.09 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |