line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Convert::Wikidata::Object::ISBN; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
128504
|
use strict; |
|
7
|
|
|
|
|
43
|
|
|
7
|
|
|
|
|
1816
|
|
4
|
7
|
|
|
7
|
|
41
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
186
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
3510
|
use Business::ISBN; |
|
7
|
|
|
|
|
407978
|
|
|
7
|
|
|
|
|
347
|
|
7
|
7
|
|
|
7
|
|
2823
|
use Error::Pure qw(err); |
|
7
|
|
|
|
|
58314
|
|
|
7
|
|
|
|
|
168
|
|
8
|
7
|
|
|
7
|
|
3096
|
use Mo qw(build is); |
|
7
|
|
|
|
|
3064
|
|
|
7
|
|
|
|
|
60
|
|
9
|
7
|
|
|
7
|
|
11980
|
use Mo::utils qw(check_isa check_required); |
|
7
|
|
|
|
|
8645
|
|
|
7
|
|
|
|
|
171
|
|
10
|
7
|
|
|
7
|
|
599
|
use List::Util qw(none); |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
729
|
|
11
|
7
|
|
|
7
|
|
47
|
use Readonly; |
|
7
|
|
|
|
|
27
|
|
|
7
|
|
|
|
|
2537
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Readonly::Array our @COVERS => qw(hardback paperback); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.01; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has cover => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has isbn => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has publisher => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub type { |
30
|
2
|
|
|
2
|
1
|
45
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
2
|
100
|
|
|
|
10
|
if ($self->{'_isbn'}->as_isbn10->as_string eq $self->{'isbn'}) { |
33
|
1
|
|
|
|
|
355
|
return 10; |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
541
|
return 13; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub BUILD { |
40
|
13
|
|
|
13
|
0
|
11039
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
57
|
check_required($self, 'isbn'); |
43
|
|
|
|
|
|
|
|
44
|
12
|
|
|
|
|
160
|
$self->{'_isbn'} = Business::ISBN->new($self->{'isbn'}); |
45
|
12
|
100
|
66
|
|
|
4213
|
if (! defined $self->{'_isbn'} || ! $self->{'_isbn'}->is_valid) { |
46
|
1
|
|
|
|
|
29
|
err "ISBN '$self->{'isbn'}' isn't valid."; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
11
|
|
|
|
|
117
|
check_isa($self, 'publisher', 'MARC::Convert::Wikidata::Object::Publisher'); |
50
|
|
|
|
|
|
|
|
51
|
11
|
100
|
|
|
|
148
|
if (defined $self->{'cover'}) { |
52
|
2
|
100
|
|
3
|
|
42
|
if (none { $self->{'cover'} eq $_ } @COVERS) { |
|
3
|
|
|
|
|
58
|
|
53
|
1
|
|
|
|
|
6
|
err "ISBN cover '$self->{'cover'}' isn't valid."; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
10
|
|
|
|
|
30
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding utf8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
MARC::Convert::Wikidata::Object::ISBN - Bibliographic Wikidata object for ISBN number defined by MARC record. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Object::ISBN; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $obj = MARC::Convert::Wikidata::Object::ISBN->new(%params); |
77
|
|
|
|
|
|
|
my $cover = $obj->cover; |
78
|
|
|
|
|
|
|
my $isbn = $obj->isbn; |
79
|
|
|
|
|
|
|
my $publisher = $obj->publisher; |
80
|
|
|
|
|
|
|
my $type = $obj->type; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 C<new> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $obj = MARC::Convert::Wikidata::Object::ISBN->new(%params); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Constructor. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns instance of object. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over 8 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * C<cover> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
ISBN cover. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Parameter is optional. Valid values are: hardback, paperback |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Default value is undef. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * C<isbn> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
ISBN number. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Parameter is required. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Default value is undef. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * C<publisher> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Publishing house object. |
113
|
|
|
|
|
|
|
Instance of MARC::Convert::Wikidata::Object::Publisher. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Default value is undef. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<cover> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $cover = $obj->cover; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Get ISBN cover. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns string. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 C<isbn> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $isbn = $obj->isbn; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Get ISBN number. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns string. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 C<publisher> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $publisher = $obj->publisher; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Get publishing house name. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns instance of MARC::Convert::Wikidata::Object::Publisher. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 C<type> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $type = $obj->type; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Get type of ISBN number (10 or 13 character length) |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns number (10 or 13). |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 ERRORS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
new(): |
154
|
|
|
|
|
|
|
Parameter 'isbn' is required. |
155
|
|
|
|
|
|
|
ISBN '%s' isn't valid. |
156
|
|
|
|
|
|
|
ISBN cover '%s' isn't valid. |
157
|
|
|
|
|
|
|
From check_isa(): |
158
|
|
|
|
|
|
|
Parameter 'publisher' must be a 'MARC::Convert::Wikidata::Object::Publisher' object. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=for comment filename=create_and_dump_isbn.pl |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
use strict; |
165
|
|
|
|
|
|
|
use warnings; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
use Data::Printer; |
168
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Object::ISBN; |
169
|
|
|
|
|
|
|
use MARC::Convert::Wikidata::Object::Publisher; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $obj = MARC::Convert::Wikidata::Object::ISBN->new( |
172
|
|
|
|
|
|
|
'isbn' => '978-80-00-05046-1', |
173
|
|
|
|
|
|
|
'publisher' => MARC::Convert::Wikidata::Object::Publisher->new( |
174
|
|
|
|
|
|
|
'name' => 'Albatros', |
175
|
|
|
|
|
|
|
), |
176
|
|
|
|
|
|
|
); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
p $obj; |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# Output: |
181
|
|
|
|
|
|
|
# MARC::Convert::Wikidata::Object::ISBN { |
182
|
|
|
|
|
|
|
# Parents Mo::Object |
183
|
|
|
|
|
|
|
# public methods (9) : BUILD, can (UNIVERSAL), DOES (UNIVERSAL), err (Error::Pure), check_isa (Mo::utils), check_required (Mo::utils), isa (UNIVERSAL), type, VERSION (UNIVERSAL) |
184
|
|
|
|
|
|
|
# private methods (1) : __ANON__ (Mo::build) |
185
|
|
|
|
|
|
|
# internals: { |
186
|
|
|
|
|
|
|
# _isbn Business::ISBN13, |
187
|
|
|
|
|
|
|
# isbn "978-80-00-05046-1", |
188
|
|
|
|
|
|
|
# publisher MARC::Convert::Wikidata::Object::Publisher |
189
|
|
|
|
|
|
|
# } |
190
|
|
|
|
|
|
|
# } |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L<Business::ISBN>, |
195
|
|
|
|
|
|
|
L<Error::Pure>, |
196
|
|
|
|
|
|
|
L<Mo>, |
197
|
|
|
|
|
|
|
L<Mo::utils>, |
198
|
|
|
|
|
|
|
L<List::Util>, |
199
|
|
|
|
|
|
|
L<Readonly>. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 SEE ALSO |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item L<MARC::Convert::Wikidata> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Conversion class between MARC record and Wikidata object. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=back |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 REPOSITORY |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/MARC-Convert-Wikidata-Object> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 AUTHOR |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
L<http://skim.cz> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
© Michal Josef Špaček 2021-2023 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
BSD 2-Clause License |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 VERSION |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
0.01 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |