File Coverage

blib/lib/Data/MARC/Field008/Book.pm
Criterion Covered Total %
statement 49 49 100.0
branch 6 6 100.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 63 64 98.4


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::Book;
2              
3 14     14   183916 use strict;
  14         41  
  14         518  
4 14     14   72 use warnings;
  14         30  
  14         1191  
5              
6 14         586 use Data::MARC::Field008::Utils qw(check_book_biography check_book_festschrift
7             check_book_illustration check_book_literary_form check_book_nature_of_content
8             check_conference_publication check_government_publication check_index
9 14     14   8693 check_item_form check_target_audience);
  14         67  
10 14     14   4103 use Error::Pure qw(err);
  14         30  
  14         816  
11 14     14   82 use Error::Pure::Utils qw(clean err_get);
  14         27  
  14         358  
12 14     14   8528 use Mo qw(build is);
  14         9676  
  14         87  
13 14     14   32658 use Mo::utils 0.22 qw(check_length_fix check_required);
  14         51153  
  14         855  
14              
15             our $STRICT = 1;
16              
17             our $VERSION = 0.04;
18              
19             has biography => (
20             is => 'ro',
21             );
22              
23             has conference_publication => (
24             is => 'ro',
25             );
26              
27             has festschrift => (
28             is => 'ro',
29             );
30              
31             has form_of_item => (
32             is => 'ro',
33             );
34              
35             has government_publication => (
36             is => 'ro',
37             );
38              
39             has illustrations => (
40             is => 'ro',
41             );
42              
43             has index => (
44             is => 'ro',
45             );
46              
47             has literary_form => (
48             is => 'ro',
49             );
50              
51             has nature_of_content => (
52             is => 'ro',
53             );
54              
55             has raw => (
56             is => 'ro',
57             );
58              
59             has target_audience => (
60             is => 'ro',
61             );
62              
63             sub BUILD {
64 15     15 0 4476665 my $self = shift;
65              
66             # Check 'raw'
67 15         153 check_length_fix($self, 'raw', 17);
68              
69             # Check 'biography'.
70 15         343 eval { check_book_biography($self, 'biography'); };
  15         107  
71              
72             # Check 'conference_publication'.
73 15         4833 eval { check_conference_publication($self, 'conference_publication'); };
  15         65  
74              
75             # Check 'festschrift'.
76 15         822 eval { check_book_festschrift($self, 'festschrift'); };
  15         53  
77              
78             # Check 'form_of_item'.
79 15         727 eval { check_item_form($self, 'form_of_item'); };
  15         65  
80              
81             # Check 'government_publication'.
82 15         850 eval { check_government_publication($self, 'government_publication'); };
  15         111  
83              
84             # Check 'illustrations'.
85 15         895 eval { check_book_illustration($self, 'illustrations'); };
  15         139  
86              
87             # Check 'index'.
88 15         785 eval { check_index($self, 'index'); };
  15         57  
89              
90             # Check 'literary_form'.
91 15         721 eval { check_book_literary_form($self, 'literary_form'); };
  15         59  
92              
93             # Check 'nature_of_content'.
94 15         811 eval { check_book_nature_of_content($self, 'nature_of_content'); };
  15         74  
95              
96             # Check 'target_audience'.
97 15         784 eval { check_target_audience($self, 'target_audience'); };
  15         72  
98              
99 15 100       1097 if ($STRICT) {
100 14         193 my @errors = err_get();
101 14 100       233 if (@errors) {
102 2 100       12 err "Couldn't create data object of book.",
103             defined $self->raw ? ('Raw string', $self->raw) : (),
104             ;
105             }
106             } else {
107 1         5 clean();
108             }
109              
110 13         82 return;
111             }
112              
113             1;
114              
115             __END__
116              
117             =pod
118              
119             =encoding utf8
120              
121             =head1 NAME
122              
123             Data::MARC::Field008::Book - Data object for MARC field 008 book material.
124              
125             =head1 SYNOPSIS
126              
127             use Data::MARC::Field008::Book;
128              
129             my $obj = Data::MARC::Field008::Book->new(%params);
130             my $biography = $obj->biography;
131             my $conference_publication = $obj->conference_publication;
132             my $festschrift = $obj->festschrift;
133             my $form_of_item = $obj->form_of_item;
134             my $government_publication = $obj->government_publication;
135             my $illustrations = $obj->illustrations;
136             my $index = $obj->index;
137             my $literary_form = $obj->literary_form;
138             my $nature_of_content = $obj->nature_of_content;
139             my $raw = $obj->raw;
140             my $target_audience = $obj->target_audience;
141              
142             =head1 METHODS
143              
144             =head2 C<new>
145              
146             my $obj = Data::MARC::Field008::Book->new(%params);
147              
148             Constructor.
149              
150             =over 8
151              
152             =item * C<biography>
153              
154             Biography. The length of the item is 1 character.
155             Possible characters are ' ', 'a', 'b', 'c', 'd' or '|'.
156              
157             It's required.
158              
159             Default value is undef.
160              
161             =item * C<conference_publication>
162              
163             Conference publication. The length of the item is 1 character.
164             Possible characters are '0', '1' or '|'.
165              
166             It's required.
167              
168             Default value is undef.
169              
170             =item * C<festschrift>
171              
172             Festschrift. The length of the item is 1 character.
173             Possible characters are '0', '1' or '|'.
174              
175             It's required.
176              
177             Default value is undef.
178              
179             =item * C<form_of_item>
180              
181             Form of item. The length of the item is 1 character.
182             Possible characters are ' ', 'a', 'b', 'c', 'd', 'f', 'o', 'q', 'r', 's' or '|'.
183              
184             It's required.
185              
186             Default value is undef.
187              
188             =item * C<government_publication>
189              
190             Government publication. The length of the string is 1 character.
191             Possible characters are ' ', 'a', 'c', 'f', 'i', 'l', 'm', 'o', 's', 'u', 'z' or '|'.
192              
193             It's required.
194              
195             Default value is undef.
196              
197             =item * C<illustrations>
198              
199             Illustrations. The length of the string is 4 characters.
200             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
201             'k', 'l', 'm', 'o', 'p' or '|'.
202              
203             It's required.
204              
205             Default value is undef.
206              
207             =item * C<index>
208              
209             Index. The length of the string is 1 character.
210             Possible characters are '0', '1' or '|'.
211              
212             It's required.
213              
214             Default value is undef.
215              
216             =item * C<literary_form>
217              
218             Literary form. The length of the string is 1 character.
219             Possible characters are '0', '1', 'd', 'e', 'f', 'h', 'i', 'j', 'm', 'p', 's',
220             'u' or '|'.
221              
222             It's required.
223              
224             Default value is undef.
225              
226             =item * C<nature_of_content>
227              
228             Nature of contents. The length of the string is 4 characters.
229             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j', 'k',
230             'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'y', 'z', '2', '5',
231             '6' or '|'.
232              
233             It's required.
234              
235             Default value is undef.
236              
237             =item * C<raw>
238              
239             Raw string of material. The length of the string is 17 characters.
240              
241             It's optional.
242              
243             Default value is undef.
244              
245             =item * C<target_audience>
246              
247             Target audience. The length of the item is 1 character.
248             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'j' or '|'.
249              
250             It's required.
251              
252             Default value is undef.
253              
254             =back
255              
256             Returns instance of object.
257              
258             =head2 C<biography>
259              
260             my $biography = $obj->biography;
261              
262             Get biography.
263              
264             Returns string.
265              
266             =head2 C<conference_publication>
267              
268             my $conference_publication = $obj->conference_publication;
269              
270             Get conference publication.
271              
272             Returns string.
273              
274             =head2 C<festschrift>
275              
276             my $festschrift = $obj->festschrift;
277              
278             Get festschrift.
279              
280             Returns string.
281              
282             =head2 C<form_of_item>
283              
284             my $form_of_item = $obj->form_of_item;
285              
286             Get form of item.
287              
288             Returns string.
289              
290             =head2 C<government_publication>
291              
292             my $government_publication = $obj->government_publication;
293              
294             Get government publication.
295              
296             Returns string.
297              
298             =head2 C<illustrations>
299              
300             my $illustrations = $obj->illustrations;
301              
302             Get illustrations.
303              
304             Returns string.
305              
306             =head2 C<index>
307              
308             my $index = $obj->index;
309              
310             Get index.
311              
312             Returns string.
313              
314             =head2 C<literary_form>
315              
316             my $literary_form = $obj->literary_form;
317              
318             Get literary form.
319              
320             Returns string.
321              
322             =head2 C<nature_of_content>
323              
324             my $nature_of_content = $obj->nature_of_content;
325              
326             Get nature of content.
327              
328             Returns string.
329              
330             =head2 C<raw>
331              
332             my $raw = $obj->raw;
333              
334             Get raw string of the block.
335              
336             Returns string.
337              
338             =head2 C<target_audience>
339              
340             my $target_audience = $obj->target_audience;
341              
342             Get target audience.
343              
344             Returns string.
345              
346             =head1 ERRORS
347              
348             new():
349             Couldn't create data object of book.
350             Raw string: %s
351             Parameter 'raw' has length different than '17'.
352             Value: %s
353             From Data::MARC::Field008::Utils::check_book_biography():
354             Parameter 'biography' has bad value.
355             Value: %s
356             Parameter 'biography' is required.
357             Parameter 'biography' length is bad.
358             Length: %s
359             Value: %s
360             Expected length: 1
361             Parameter 'biography' must be a scalar value.
362             Reference: %s
363             From Data::MARC::Field008::Utils::check_book_festschrift():
364             Parameter 'festschrift' has bad value.
365             Value: %s
366             Parameter 'festschrift' is required.
367             Parameter 'festschrift' length is bad.
368             Length: %s
369             Value: %s
370             Expected length: 1
371             Parameter 'festschrift' must be a scalar value.
372             Reference: %s
373             From Data::MARC::Field008::Utils::check_book_illustration():
374             Parameter 'illustrations' contains bad book illustration character.
375             Value: %s
376             Parameter 'illustrations' has value with pipe character.
377             Value: %s
378             Parameter 'illustrations' is required.
379             Parameter 'illustrations' length is bad.
380             Length: %s
381             Value: %s
382             Expected length: 4
383             Parameter 'illustrations' must be a scalar value.
384             Reference: %s
385             From Data::MARC::Field008::Utils::check_book_literary_form():
386             Parameter 'literary_form' has bad value.
387             Value: %s
388             Parameter 'literary_form' is required.
389             Parameter 'literary_form' length is bad.
390             Length: %s
391             Value: %s
392             Expected length: 1
393             Parameter 'literary_form' must be a scalar value.
394             Reference: %s
395             From Data::MARC::Field008::Utils::check_book_nature_of_content():
396             Parameter 'nature_of_content' has bad value.
397             Value: %s
398             Parameter 'nature_of_content' has value with pipe character.
399             Value: %s
400             Parameter 'nature_of_content' is required.
401             Parameter 'nature_of_content' length is bad.
402             Length: %s
403             Value: %s
404             Expected length: 4
405             Parameter 'nature_of_content' must be a scalar value.
406             Reference: %s
407             From Data::MARC::Field008::Utils::check_conference_publication():
408             Parameter 'conference_publication' has bad value.
409             Value: %s
410             Parameter 'conference_publication' is required.
411             Parameter 'conference_publication' length is bad.
412             Length: %s
413             Value: %s
414             Expected length: 1
415             Parameter 'conference_publication' must be a scalar value.
416             Reference: %s
417             From Data::MARC::Field008::Utils::check_government_publication():
418             Parameter 'government_publication' has bad value.
419             Value: %s
420             Parameter 'government_publication' is required.
421             Parameter 'government_publication' length is bad.
422             Length: %s
423             Value: %s
424             Expected length: 1
425             Parameter 'government_publication' must be a scalar value.
426             Reference: %s
427             From Data::MARC::Field008::Utils::check_index():
428             Parameter 'index' has bad value.
429             Value: %s
430             Parameter 'index' is required.
431             Parameter 'index' length is bad.
432             Length: %s
433             Value: %s
434             Expected length: 1
435             Parameter 'index' must be a scalar value.
436             Reference: %s
437             From Data::MARC::Field008::Utils::check_item_form():
438             Parameter 'form_of_item' has bad value.
439             Value: %s
440             Parameter 'form_of_item' is required.
441             Parameter 'form_of_item' length is bad.
442             Length: %s
443             Value: %s
444             Expected length: 1
445             Parameter 'form_of_item' must be a scalar value.
446             Reference: %s
447             From Data::MARC::Field008::Utils::check_target_audience():
448             Parameter 'target_audience' has bad value.
449             Value: %s
450             Parameter 'target_audience' is required.
451             Parameter 'target_audience' length is bad.
452             Length: %s
453             Value: %s
454             Expected length: 1
455             Parameter 'target_audience' must be a scalar value.
456             Reference: %s
457              
458             =head1 EXAMPLE
459              
460             =for comment filename=create_and_dump_marc_field_008_book.pl
461              
462             use strict;
463             use warnings;
464              
465             use Data::Printer;
466             use Data::MARC::Field008::Book;
467              
468             # cnb000000096
469             my $obj = Data::MARC::Field008::Book->new(
470             'biography' => ' ',
471             'conference_publication' => '0',
472             'festschrift' => '|',
473             'form_of_item' => ' ',
474             'government_publication' => 'u',
475             'illustrations' => 'a ',
476             'index' => '0',
477             'literary_form' => '|',
478             'nature_of_content' => ' ',
479             # 89012345678901234
480             'raw' => 'a u0|0 | ',
481             'target_audience' => ' ',
482             );
483              
484             # Print out.
485             p $obj;
486              
487             # Output:
488             # Data::MARC::Field008::Book {
489             # parents: Mo::Object
490             # public methods (15):
491             # BUILD
492             # Data::MARC::Field008::Utils:
493             # check_book_biography, check_book_festschrift, check_book_illustration, check_book_literary_form, check_book_nature_of_content, check_conference_publication, check_government_publication, check_index, check_item_form, check_target_audience
494             # Error::Pure:
495             # err
496             # Error::Pure::Utils:
497             # err_get
498             # Mo::utils:
499             # check_length_fix, check_required
500             # private methods (0)
501             # internals: {
502             # biography " ",
503             # conference_publication 0,
504             # festschrift "|",
505             # form_of_item " ",
506             # government_publication "u",
507             # illustrations "a ",
508             # index 0,
509             # literary_form "|",
510             # nature_of_content " ",
511             # raw "a u0|0 | ",
512             # target_audience " "
513             # }
514             # }
515              
516             =head1 DEPENDENCIES
517              
518             L<Data::MARC::Field008::Utils>,
519             L<Error::Pure>
520             L<Error::Pure::Utils>
521             L<Mo>,
522             L<Mo::utils>.
523              
524             =head1 REPOSITORY
525              
526             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
527              
528             =head1 AUTHOR
529              
530             Michal Josef Špaček L<mailto:skim@cpan.org>
531              
532             L<http://skim.cz>
533              
534             =head1 LICENSE AND COPYRIGHT
535              
536             © 2025 Michal Josef Špaček
537              
538             BSD 2-Clause License
539              
540             =head1 ACKNOWLEDGEMENTS
541              
542             Development of this software has been made possible by institutional support
543             for the long-term strategic development of the National Library of the Czech
544             Republic as a research organization provided by the Ministry of Culture of
545             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
546              
547             =head1 VERSION
548              
549             0.04
550              
551             =cut