line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Print::Value::Item; |
2
|
|
|
|
|
|
|
|
3
|
48
|
|
|
48
|
|
916043
|
use base qw(Exporter); |
|
48
|
|
|
|
|
133
|
|
|
48
|
|
|
|
|
4403
|
|
4
|
48
|
|
|
48
|
|
331
|
use strict; |
|
48
|
|
|
|
|
120
|
|
|
48
|
|
|
|
|
950
|
|
5
|
48
|
|
|
48
|
|
243
|
use warnings; |
|
48
|
|
|
|
|
119
|
|
|
48
|
|
|
|
|
1506
|
|
6
|
|
|
|
|
|
|
|
7
|
48
|
|
|
48
|
|
1248
|
use Error::Pure qw(err); |
|
48
|
|
|
|
|
22920
|
|
|
48
|
|
|
|
|
1934
|
|
8
|
48
|
|
|
48
|
|
516
|
use Readonly; |
|
48
|
|
|
|
|
130
|
|
|
48
|
|
|
|
|
10799
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(print); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.13; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub print { |
15
|
32
|
|
|
32
|
1
|
6826
|
my ($obj, $opts_hr) = @_; |
16
|
|
|
|
|
|
|
|
17
|
32
|
100
|
|
|
|
140
|
if (! $obj->isa('Wikibase::Datatype::Value::Item')) { |
18
|
1
|
|
|
|
|
5
|
err "Object isn't 'Wikibase::Datatype::Value::Item'."; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
31
|
100
|
100
|
|
|
188
|
if (exists $opts_hr->{'cb'} && ! $opts_hr->{'cb'}->isa('Wikibase::Cache')) { |
22
|
1
|
|
|
|
|
4
|
err "Option 'cb' must be a instance of Wikibase::Cache."; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
30
|
|
|
|
|
67
|
my $item; |
26
|
30
|
100
|
|
|
|
89
|
if (exists $opts_hr->{'cb'}) { |
27
|
2
|
|
66
|
|
|
7
|
$item = $opts_hr->{'cb'}->get('label', $obj->value) || $obj->value; |
28
|
|
|
|
|
|
|
} else { |
29
|
28
|
|
|
|
|
140
|
$item = $obj->value; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
30
|
|
|
|
|
394
|
return $item; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding utf8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Wikibase::Datatype::Print::Value::Item - Wikibase item value pretty print helpers. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Value::Item qw(print); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
52
|
|
|
|
|
|
|
my @pretty_print_lines = print($obj, $opts_hr); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SUBROUTINES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 C<print> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $pretty_print_string = print($obj, $opts_hr); |
59
|
|
|
|
|
|
|
my @pretty_print_lines = print($obj, $opts_hr); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Construct pretty print output for L<Wikibase::Datatype::Value::Item> |
62
|
|
|
|
|
|
|
object. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns string in scalar context. |
65
|
|
|
|
|
|
|
Returns list of lines in array context. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 ERRORS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
print(): |
70
|
|
|
|
|
|
|
Object isn't 'Wikibase::Datatype::Value::Item'. |
71
|
|
|
|
|
|
|
Option 'cb' must be a instance of Wikibase::Cache. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 EXAMPLE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=for comment filename=create_and_print_value_item.pl |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use strict; |
78
|
|
|
|
|
|
|
use warnings; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use Wikibase::Datatype::Print::Value::Item; |
81
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Item; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Object. |
84
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Value::Item->new( |
85
|
|
|
|
|
|
|
'value' => 'Q123', |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Print. |
89
|
|
|
|
|
|
|
print Wikibase::Datatype::Print::Value::Item::print($obj)."\n"; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Output: |
92
|
|
|
|
|
|
|
# Q123 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L<Error::Pure>, |
97
|
|
|
|
|
|
|
L<Exporter>, |
98
|
|
|
|
|
|
|
L<Readonly>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SEE ALSO |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Value::Item> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Wikibase item value datatype. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 REPOSITORY |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype-Print> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<http://skim.cz> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
BSD 2-Clause License |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 VERSION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
0.13 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |