File Coverage

blib/lib/Data/MARC/Field008/Music.pm
Criterion Covered Total %
statement 43 45 95.5
branch 2 6 33.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 53 60 88.3


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::Music;
2              
3 11     11   158245 use strict;
  11         20  
  11         443  
4 11     11   60 use warnings;
  11         21  
  11         918  
5              
6 11         402 use Data::MARC::Field008::Utils qw(check_item_form
7             check_music_accompanying_matter check_music_composition_form
8             check_music_format check_music_literary_text check_music_parts
9 11     11   7787 check_music_transposition_and_arrangement check_target_audience);
  11         54  
10 11     11   10652 use Error::Pure qw(err);
  11         29  
  11         854  
11 11     11   124 use Error::Pure::Utils qw(clean err_get);
  11         22  
  11         289  
12 11     11   7699 use Mo qw(build is);
  11         7954  
  11         66  
13 11     11   28644 use Mo::utils 0.22 qw(check_length_fix check_required);
  11         41357  
  11         338  
14              
15             our $STRICT = 1;
16              
17             our $VERSION = 0.04;
18              
19             has accompanying_matter => (
20             is => 'ro',
21             );
22              
23             has form_of_composition => (
24             is => 'ro',
25             );
26              
27             has form_of_item => (
28             is => 'ro',
29             );
30              
31             has format_of_music => (
32             is => 'ro',
33             );
34              
35             has literary_text_for_sound_recordings => (
36             is => 'ro',
37             );
38              
39             has music_parts => (
40             is => 'ro',
41             );
42              
43             has raw => (
44             is => 'ro',
45             );
46              
47             has target_audience => (
48             is => 'ro',
49             );
50              
51             has transposition_and_arrangement => (
52             is => 'ro',
53             );
54              
55             sub BUILD {
56 11     11 0 3380746 my $self = shift;
57              
58             # Check 'raw'
59 11         72 check_length_fix($self, 'raw', 17);
60              
61             # Check 'accompanying_matter'.
62 10         206 eval { check_music_accompanying_matter($self, 'accompanying_matter'); };
  10         135  
63              
64             # Check 'form_of_composition'.
65 10         22 eval { check_music_composition_form($self, 'form_of_composition'); };
  10         37  
66              
67             # Check 'form_of_item'.
68 10         26 eval { check_item_form($self, 'form_of_item'); };
  10         49  
69              
70             # Check 'format_of_music'.
71 10         25 eval { check_music_format($self, 'format_of_music'); };
  10         53  
72              
73             # Check 'literary_text_for_sound_recordings'.
74 10         24 eval { check_music_literary_text($self, 'literary_text_for_sound_recordings'); };
  10         44  
75              
76             # Check 'music_parts'.
77 10         55 eval { check_music_parts($self, 'music_parts'); };
  10         120  
78              
79             # Check 'target_audience'.
80 10         25 eval { check_target_audience($self, 'target_audience'); };
  10         41  
81              
82             # Check 'transposition_and_arrangement'.
83 10         24 eval { check_music_transposition_and_arrangement($self, 'transposition_and_arrangement'); };
  10         35  
84              
85 10 50       43 if ($STRICT) {
86 10         63 my @errors = err_get();
87 10 50       118 if (@errors) {
88 0 0       0 err "Couldn't create data object of music.",
89             defined $self->raw ? ('Raw string', $self->raw) : (),
90             ;
91             }
92             } else {
93 0         0 clean();
94             }
95              
96 10         32 return;
97             }
98              
99             1;
100              
101             __END__
102              
103             =pod
104              
105             =encoding utf8
106              
107             =head1 NAME
108              
109             Data::MARC::Field008::Music - Data object for MARC field 008 music material.
110              
111             =head1 SYNOPSIS
112              
113             use Data::MARC::Field008::Music;
114              
115             my $obj = Data::MARC::Field008::Music->new(%params);
116             my $accompanying_matter = $obj->accompanying_matter;
117             my $form_of_composition = $obj->form_of_composition;
118             my $form_of_item = $obj->form_of_item;
119             my $format_of_music = $obj->format_of_music;
120             my $literary_text_for_sound_recordings = $obj->literary_text_for_sound_recordings;
121             my $music_parts = $obj->music_parts;
122             my $raw = $obj->raw;
123             my $target_audience = $obj->target_audience;
124             my $transposition_and_arrangement = $obj->transposition_and_arrangement;
125              
126             =head1 METHODS
127              
128             =head2 C<new>
129              
130             my $obj = Data::MARC::Field008::Music->new(%params);
131              
132             Constructor.
133              
134             =over 8
135              
136             =item * C<accompanying_matter>
137              
138             Accompanying matter. The length of the string is 6 characters.
139             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k',
140             'r', 's', 'z' or '|'.
141              
142             It's required.
143              
144             Default value is undef.
145              
146             =item * C<form_of_composition>
147              
148             Form of composition. The length of the string is 2 characters.
149             Possible strings are 'an', 'bd', 'bg', 'bl', bt', 'ca', 'cb', 'cc', 'cg', 'ch',
150             'cl', 'cn', 'co', 'cp', 'cr', 'cs', 'ct', 'cy', 'cz', 'df', 'dv', 'fg', 'fl',
151             'fm', 'ft', 'gm', 'hy', 'jz', 'mc', 'md', 'mi', 'mo', 'mp', 'mr', 'ms', 'mu',
152             'mz', 'nc', 'nn', 'op', 'or', 'ov', 'pg', 'pm', 'po', 'pp', 'pr', 'ps', 'pt',
153             'pv', 'rc', 'rd', 'rg', 'ri', 'rp', 'rq', 'sd', 'sg', 'sn', 'sp', 'st', 'su',
154             'sy', 'tc', 'tl', 'ts', 'uu', 'vi', 'vr', 'wz', 'za', 'zz' or '||'.
155              
156             It's required.
157              
158             Default value is undef.
159              
160             =item * C<form_of_item>
161              
162             Form of item. The length of the item is 1 character.
163             Possible characters are ' ', 'a', 'b', 'c', 'd', 'f', 'o', 'q', 'r', 's' or '|'.
164              
165             It's required.
166              
167             Default value is undef.
168              
169             =item * C<format_of_music>
170              
171             Format of music. The length of the item is 1 character.
172             Possible characters are 'a', 'b', 'c', 'd', 'e', 'g', 'h', 'i', 'j', 'k', 'l',
173             'm', 'n', 'p', 'u', 'z' or '|'.
174              
175             It's required.
176              
177             Default value is undef.
178              
179             =item * C<literary_text_for_sound_recordings>
180              
181             Literary text for sound recordings. The length of the item is 2 characters.
182             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
183             'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'z' or '|'.
184              
185             It's required.
186              
187             Default value is undef.
188              
189             =item * C<music_parts>
190              
191             Music parts. The length of the item is 1 character.
192             Possible characters are ' ', 'd', 'e', 'f', 'n', 'u' or '|'.
193              
194             It's required.
195              
196             Default value is undef.
197              
198             =item * C<raw>
199              
200             Raw string of material. The length of the string is 17 characters.
201              
202             It's optional.
203              
204             Default value is undef.
205              
206             =item * C<target_audience>
207              
208             Target audience. The length of the item is 1 character.
209             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'j' or '|'.
210              
211             It's required.
212              
213             Default value is undef.
214              
215             =item * C<transposition_and_arrangement>
216              
217             Transposition and arrangement. The length of the item is 1 character.
218             Possible characters are ' ', 'a', 'b', 'c', 'n', 'u' or '|'.
219              
220             It's required.
221              
222             Default value is undef.
223              
224             =back
225              
226             Returns instance of object.
227              
228             =head2 C<accompanying_matter>
229              
230             my $accompanying_matter = $obj->accompanying_matter;
231              
232             Get accompanying matter.
233              
234             Returns string.
235              
236             =head2 C<form_of_composition>
237              
238             my $form_of_composition = $obj->form_of_composition;
239              
240             Get form of composition.
241              
242             Returns string.
243              
244             =head2 C<form_of_item>
245              
246             my $form_of_item = $obj->form_of_item;
247              
248             Get form of item.
249              
250             Returns string.
251              
252             =head2 C<format_of_music>
253              
254             my $format_of_music = $obj->format_of_music;
255              
256             Get format of music.
257              
258             Returns string.
259              
260             =head2 C<literary_text_for_sound_recordings>
261              
262             my $literary_text_for_sound_recordings = $obj->literary_text_for_sound_recordings;
263              
264             Get literary text for sound recordings.
265              
266             Returns string.
267              
268             =head2 C<music_parts>
269              
270             my $music_parts = $obj->music_parts;
271              
272             Get music parts.
273              
274             Returns string.
275              
276             =head2 C<raw>
277              
278             my $raw = $obj->form_of_item;
279              
280             Get raw string of the block.
281              
282             Returns string.
283              
284             =head2 C<target_audience>
285              
286             my $target_audience = $obj->target_audience;
287              
288             Get target audience.
289              
290             Returns string.
291              
292             =head2 C<transposition_and_arrangement>
293              
294             my $transposition_and_arrangement = $obj->transposition_and_arrangement;
295              
296             Get transposition and arrangement.
297              
298             Returns string.
299              
300             =head1 ERRORS
301              
302             new():
303             Couldn't create data object of music.
304             Raw string: %s
305             Parameter 'raw' has length different than '17'.
306             Value: %s
307             From Data::MARC::Field008::Utils::check_item_form():
308             Parameter 'form_of_item' has bad value.
309             Value: %s
310             Parameter 'form_of_item' is required.
311             Parameter 'form_of_item' length is bad.
312             Length: %s
313             Value: %s
314             Expected length: 1
315             Parameter 'form_of_item' must be a scalar value.
316             Reference: %s
317             From Data::MARC::Field008::Utils::check_music_accompanying_matter():
318             Parameter 'accompanying_matter' contains bad music accompanying matter character.
319             Value: %s
320             Parameter 'accompanying_matter' is required.
321             Parameter 'accompanying_matter' must be a scalar value.
322             Reference: %s
323             Parameter 'accompanying_matter' length is bad.
324             Length: %s
325             Value: %s
326             Expected length: 6
327             From Data::MARC::Field008::Utils::check_music_composition_form():
328             Parameter 'form_of_composition' has bad value.
329             Value: %s
330             Parameter 'form_of_composition' is required.
331             Parameter 'check_music_composition_form' length is bad.
332             Length: %s
333             Value: %s
334             Expected length: 2
335             Parameter 'check_music_composition_form' must be a scalar value.
336             Reference: %s
337             From Data::MARC::Field008::Utils::check_music_format():
338             Parameter 'format_of_music' has bad value.
339             Value: %s
340             Parameter 'format_of_music' is required.
341             Parameter 'format_of_music' length is bad.
342             Length: %s
343             Value: %s
344             Expected length: 1
345             Parameter 'format_of_music' must be a scalar value.
346             Reference: %s
347             From Data::MARC::Field008::Utils::check_music_literary_text():
348             Parameter 'literary_text_for_sound_recordings' contains bad music literary text character.
349             Value: %s
350             Parameter 'literary_text_for_sound_recordings' has value with pipe character.
351             Value: %s
352             Parameter 'literary_text_for_sound_recordings' is required.
353             Parameter 'literary_text_for_sound_recordings' must be a scalar value.
354             Reference: %s
355             Parameter 'literary_text_for_sound_recordings' length is bad.
356             Length: %s
357             Value: %s
358             Expected length: 2
359             From Data::MARC::Field008::Utils::check_music_parts():
360             Parameter 'music_parts' has bad value.
361             Value: %s
362             Parameter 'music_parts' is required.
363             Parameter 'music_parts' length is bad.
364             Length: %s
365             Value: %s
366             Expected length: 1
367             Parameter 'music_parts' must be a scalar value.
368             Reference: %s
369             From Data::MARC::Field008::Utils::check_music_transposition_and_arrangement():
370             Parameter 'transposition_and_arrangement' has bad value.
371             Value: %s
372             Parameter 'transposition_and_arrangement' is required.
373             Parameter 'transposition_and_arrangement' length is bad.
374             Length: %s
375             Value: %s
376             Expected length: 1
377             Parameter 'transposition_and_arrangement' must be a scalar value.
378             Reference: %s
379             From Data::MARC::Field008::Utils::check_target_audience():
380             Parameter 'target_audience' has bad value.
381             Value: %s
382             Parameter 'target_audience' is required.
383             Parameter 'target_audience' length is bad.
384             Length: %s
385             Value: %s
386             Expected length: 1
387             Parameter 'target_audience' must be a scalar value.
388             Reference: %s
389              
390             =head1 EXAMPLE
391              
392             =for comment filename=create_and_dump_marc_field_008_music_material.pl
393              
394             use strict;
395             use warnings;
396              
397             use Data::Printer;
398             use Data::MARC::Field008::Music;
399              
400             # cnb000012142
401             my $obj = Data::MARC::Field008::Music->new(
402             'accompanying_matter' => ' ',
403             'form_of_composition' => 'sg',
404             'form_of_item' => ' ',
405             'format_of_music' => 'z',
406             'literary_text_for_sound_recordings' => 'nn',
407             'music_parts' => ' ',
408             # 89012345678901234
409             'raw' => 'sgz g nn ',
410             'target_audience' => 'g',
411             'transposition_and_arrangement' => ' ',
412             );
413              
414             # Print out.
415             p $obj;
416              
417             # Output:
418             # Data::MARC::Field008::Music {
419             # parents: Mo::Object
420             # public methods (13):
421             # BUILD
422             # Data::MARC::Field008::Utils:
423             # check_item_form, check_music_accompanying_matter, check_music_composition_form, check_music_format, check_music_literary_text, check_music_parts, check_music_transposition_and_arrangement, check_target_audience
424             # Error::Pure:
425             # err
426             # Error::Pure::Utils:
427             # err_get
428             # Mo::utils:
429             # check_length_fix, check_required
430             # private methods (0)
431             # internals: {
432             # accompanying_matter " ",
433             # format_of_music "z",
434             # form_of_composition "sg",
435             # form_of_item " ",
436             # literary_text_for_sound_recordings "nn",
437             # music_parts " ",
438             # raw "sgz g nn ",
439             # target_audience "g",
440             # transposition_and_arrangement " "
441             # }
442             # }
443              
444             =head1 DEPENDENCIES
445              
446             L<Data::MARC::Field008::Utils>,
447             L<Error::Pure>
448             L<Error::Pure::Utils>
449             L<Mo>,
450             L<Mo::utils>.
451              
452             =head1 REPOSITORY
453              
454             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
455              
456             =head1 AUTHOR
457              
458             Michal Josef Špaček L<mailto:skim@cpan.org>
459              
460             L<http://skim.cz>
461              
462             =head1 LICENSE AND COPYRIGHT
463              
464             © 2025 Michal Josef Špaček
465              
466             BSD 2-Clause License
467              
468             =head1 ACKNOWLEDGEMENTS
469              
470             Development of this software has been made possible by institutional support
471             for the long-term strategic development of the National Library of the Czech
472             Republic as a research organization provided by the Ministry of Culture of
473             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
474              
475             =head1 VERSION
476              
477             0.04
478              
479             =cut