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