File Coverage

blib/lib/Data/MARC/Leader.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             package Data::MARC::Leader;
2              
3 5     5   132042 use strict;
  5         10  
  5         203  
4 5     5   31 use warnings;
  5         31  
  5         343  
5              
6 5     5   2400 use Mo qw(build is);
  5         3475  
  5         30  
7 5     5   11958 use Mo::utils 0.22 qw(check_length_fix check_strings);
  5         104988  
  5         138  
8 5     5   1008 use Readonly;
  5         12  
  5         4268  
9              
10             Readonly::Array our @BIBLIOGRAPHIC_LEVEL => qw(a b c d i m s);
11             Readonly::Array our @CHAR_CODING_SCHEME => (' ', 'a');
12             Readonly::Array our @DESCRIPTIVE_CATALOGING_FORM => (' ', 'a', 'c', 'i', 'n', 'u');
13             Readonly::Array our @ENCODING_LEVEL => (' ', 1, 2, 3, 4, 5, 7, 8, 'u', 'z');
14             Readonly::Array our @IMPL_DEF_PORTION_LEN => qw(0);
15             Readonly::Array our @INDICATOR_COUNT => qw(2);
16             Readonly::Array our @LENGTH_OF_FIELD_PORTION_LEN => qw(4);
17             Readonly::Array our @MULTIPART_RESORCE_RECORD_LEVEL => (' ', 'a', 'b', 'c');
18             Readonly::Array our @STARTING_CHAR_POS_PORTION_LEN => qw(5);
19             Readonly::Array our @STATUS => qw(a c d n p);
20             Readonly::Array our @SUBFIELD_CODE_COUNT => qw(2);
21             Readonly::Array our @TYPE => qw(a c d e f g i j k m o p r t);
22             Readonly::Array our @TYPE_OF_CONTROL => (' ', 'a');
23             Readonly::Array our @UNDEFINED => ('0');
24              
25             our $VERSION = 0.07;
26              
27             has bibliographic_level => (
28             is => 'ro',
29             );
30              
31             has char_coding_scheme => (
32             is => 'ro',
33             );
34              
35             has data_base_addr => (
36             is => 'ro',
37             );
38              
39             has descriptive_cataloging_form => (
40             is => 'ro',
41             );
42              
43             has encoding_level => (
44             is => 'ro',
45             );
46              
47             has impl_def_portion_len => (
48             is => 'ro',
49             );
50              
51             has indicator_count => (
52             is => 'ro',
53             );
54              
55             has length => (
56             is => 'ro',
57             );
58              
59             has length_of_field_portion_len => (
60             is => 'ro',
61             );
62              
63             has multipart_resource_record_level => (
64             is => 'ro',
65             );
66              
67             has raw => (
68             is => 'ro',
69             );
70              
71             has starting_char_pos_portion_len => (
72             is => 'ro',
73             );
74              
75             has status => (
76             is => 'ro',
77             );
78              
79             has subfield_code_count => (
80             is => 'ro',
81             );
82              
83             has type => (
84             is => 'ro',
85             );
86              
87             has type_of_control => (
88             is => 'ro',
89             );
90              
91             has undefined => (
92             is => 'ro',
93             );
94              
95             sub BUILD {
96 21     21 0 1050821 my $self = shift;
97              
98             # Check bibliographic_level.
99 21         118 check_strings($self, 'bibliographic_level', \@BIBLIOGRAPHIC_LEVEL);
100              
101             # Check char_coding_scheme.
102 20         399 check_strings($self, 'char_coding_scheme', \@CHAR_CODING_SCHEME);
103              
104             # Check descriptive_cataloging_form.
105 19         487 check_strings($self, 'descriptive_cataloging_form',
106             \@DESCRIPTIVE_CATALOGING_FORM);
107              
108             # Check encoding_level.
109 18         295 check_strings($self, 'encoding_level', \@ENCODING_LEVEL);
110              
111             # Check impl_def_portion_len.
112 17         263 check_strings($self, 'impl_def_portion_len', \@IMPL_DEF_PORTION_LEN);
113              
114             # Check indicator_count.
115 16         269 check_strings($self, 'indicator_count', \@INDICATOR_COUNT);
116              
117             # Check length.
118             # TODO
119              
120             # Check length_of_field_portion_len.
121 15         208 check_strings($self, 'length_of_field_portion_len',
122             \@LENGTH_OF_FIELD_PORTION_LEN);
123              
124             # Check multipart_resource_record_level.
125 14         180 check_strings($self, 'multipart_resource_record_level',
126             \@MULTIPART_RESORCE_RECORD_LEVEL);
127              
128             # Check raw.
129 13         184 check_length_fix($self, 'raw', 24);
130              
131             # Check starting_char_pos_portion_len.
132 12         201 check_strings($self, 'starting_char_pos_portion_len',
133             \@STARTING_CHAR_POS_PORTION_LEN);
134              
135             # Check status.
136 11         161 check_strings($self, 'status', \@STATUS);
137              
138             # Check subfield_code_count.
139 10         156 check_strings($self, 'subfield_code_count', \@SUBFIELD_CODE_COUNT);
140              
141             # Check type.
142 9         170 check_strings($self, 'type', \@TYPE);
143              
144             # Check type_of_control.
145 8         178 check_strings($self, 'type_of_control', \@TYPE_OF_CONTROL);
146              
147             # Check undefined.
148 7         106 check_strings($self, 'undefined', \@UNDEFINED);
149              
150 6         97 return;
151             }
152              
153             1;
154              
155             __END__
156              
157             =pod
158              
159             =encoding utf8
160              
161             =head1 NAME
162              
163             Data::MARC::Leader - Data object for MARC leader.
164              
165             =head1 SYNOPSIS
166              
167             use Data::MARC::Leader;
168              
169             my $obj = Data::MARC::Leader->new(%params);
170             my $bibliographic_level = $obj->bibliographic_level;
171             my $char_coding_scheme = $obj->char_coding_scheme;
172             my $data_base_addr = $obj->data_base_addr;
173             my $descriptive_cataloging_form = $obj->descriptive_cataloging_form;
174             my $encoding_level = $obj->encoding_level;
175             my $impl_def_portion_len = $obj->impl_def_portion_len;
176             my $indicator_count = $obj->indicator_count;
177             my $length = $obj->length;
178             my $length_of_field_portion_len = $obj->length_of_field_portion_len;
179             my $multipart_resource_record_level = $obj->multipart_resource_record_level;
180             my $raw = $obj->raw;
181             my $starting_char_pos_portion_len = $obj->starting_char_pos_portion_len;
182             my $status = $obj->status;
183             my $subfield_code_count = $obj->subfield_code_count;
184             my $type = $obj->type;
185             my $type_of_control = $obj->type_of_control;
186             my $undefined = $obj->undefined;
187              
188             =head1 METHODS
189              
190             =head2 C<new>
191              
192             my $obj = Data::MARC::Leader->new(%params);
193              
194             Constructor.
195              
196             =over 8
197              
198             =item * C<bibliographic_level>
199              
200             Bibliographic level flag.
201              
202             Default values is undef.
203              
204             =item * C<char_coding_scheme>
205              
206             Character coding scheme.
207              
208             Default values is undef.
209              
210             =item * C<data_base_addr>
211              
212             Base address of data.
213              
214             Default values is undef.
215              
216             =item * C<descriptive_cataloging_form>
217              
218             Descriptive cataloging form.
219              
220             Default values is undef.
221              
222             =item * C<encoding_level>
223              
224             Encoding level.
225              
226             Default values is undef.
227              
228             =item * C<impl_def_portion_len>
229              
230             Length of the implementation-defined portion.
231              
232             Default values is undef.
233              
234             =item * C<indicator_count>
235              
236             Indicator count.
237              
238             Default values is undef.
239              
240             =item * C<length>
241              
242             Record length.
243              
244             Default values is undef.
245              
246             =item * C<length_of_field_portion_len>
247              
248             Length of the length-of-field portion.
249              
250             Default values is undef.
251              
252             =item * C<multipart_resource_record_level>
253              
254             Multipart resource record level.
255              
256             Default values is undef.
257              
258             =item * C<raw>
259              
260             Raw leader value.
261              
262             Default values is undef.
263              
264             =item * C<starting_char_pos_portion_len>
265              
266             Length of the starting-character-position portion.
267              
268             Default values is undef.
269              
270             =item * C<status>
271              
272             Record status.
273              
274             Default values is undef.
275              
276             =item * C<subfield_code_count>
277              
278             Subfield code count.
279              
280             Default values is undef.
281              
282             =item * C<type>
283              
284             Type of record.
285              
286             Default values is undef.
287              
288             =item * C<type_of_control>
289              
290             Type of control.
291              
292             Default values is undef.
293              
294             =item * C<undefined>
295              
296             Undefined.
297              
298             Default values is undef.
299              
300             =back
301              
302             Returns instance of object.
303              
304             =head2 C<bibliographic_level>
305              
306             my $bibliographic_level = $obj->bibliographic_level;
307              
308             Get bibliographic level flag.
309              
310             Returns character.
311              
312             =head2 C<char_coding_scheme>
313              
314             my $char_coding_scheme = $obj->char_coding_scheme;
315              
316             Get character coding scheme.
317              
318             Returns character.
319              
320             =head2 C<data_base_addr>
321              
322             my $data_base_addr = $obj->data_base_addr;
323              
324             Get base address of data.
325              
326             Returns number.
327              
328             =head2 C<descriptive_cataloging_form>
329              
330             my $descriptive_cataloging_form = $obj->descriptive_cataloging_form;
331              
332             Get descriptive cataloging form.
333              
334             Returns character.
335              
336             =head2 C<encoding_level>
337              
338             my $encoding_level = $obj->encoding_level;
339              
340             Get encoding level.
341              
342             Returns character.
343              
344             =head2 C<impl_def_portion_len>
345              
346             my $impl_def_portion_len = $obj->impl_def_portion_len;
347              
348             Get length of the implementation-defined portion.
349              
350             Returns character.
351              
352             =head2 C<indicator_count>
353              
354             my $indicator_count = $obj->indicator_count;
355              
356             Get indicator count.
357              
358             Returns character.
359              
360             =head2 C<length>
361              
362             my $length = $obj->length;
363              
364             Get record length.
365              
366             Returns number.
367              
368             =head2 C<length_of_field_portion_len>
369              
370             my $length_of_field_portion_len = $obj->length_of_field_portion_len;
371              
372             Get length of the length-of-field portion
373              
374             Returns character.
375              
376             =head2 C<multipart_resource_record_level>
377              
378             my $multipart_resource_record_level = $obj->multipart_resource_record_level;
379              
380             Get multipart resource record level.
381              
382             Returns character.
383              
384             =head2 C<raw>
385              
386             my $raw = $obj->raw;
387              
388             Get raw leader value.
389              
390             Returns string.
391              
392             =head2 C<starting_char_pos_portion_len>
393              
394             my $starting_char_pos_portion_len = $obj->starting_char_pos_portion_len;
395              
396             Get length of the starting-character-position portion.
397              
398             Returns character.
399              
400             =head2 C<status>
401              
402             my $status = $obj->status;
403              
404             Get record status.
405              
406             Returns character.
407              
408             =head2 C<subfield_code_count>
409              
410             my $subfield_code_count = $obj->subfield_code_count;
411              
412             Get subfield code count.
413              
414             Returns character.
415              
416             =head2 C<type>
417              
418             my $type = $obj->type;
419              
420             Get type of record.
421              
422             Returns character.
423              
424             =head2 C<type_of_control>
425              
426             my $type_of_control = $obj->type_of_control;
427              
428             Get type of control.
429              
430             Returns character.
431              
432             =head2 C<undefined>
433              
434             my $undefined = $obj->undefined;
435              
436             Get undefined.
437              
438             Returns character.
439              
440             =head1 ERRORS
441              
442             new():
443             Parameter 'bibliographic_level' must be one of defined strings.
444             String: %s
445             Possible strings: a b c d i m s
446             Parameter 'char_coding_scheme' must be one of defined strings.
447             String: %s
448             Possible strings: ' ' a
449             Parameter 'descriptive_cataloging_form' must be one of defined strings.
450             String: %s
451             Possible strings: ' ' a c i n u
452             Parameter 'encoding_level' must be one of defined strings.
453             String: %s
454             Possible strings: ' ' 1 2 3 4 5 7 8 u z
455             Parameter 'impl_def_portion_len' must be one of defined strings.
456             String: %s
457             Possible strings: 0
458             Parameter 'indicator_count' must be one of defined strings.
459             String: %s
460             Possible strings: 2
461             Parameter 'length_of_field_portion_len' must be one of defined strings.
462             String: %s
463             Possible strings: 4
464             Parameter 'multipart_resource_record_level' must be one of defined strings.
465             String: %s
466             Possible strings: ' ' a b c
467             Parameter 'raw' has length different than '24'.
468             Value: %s
469             Parameter 'starting_char_pos_portion_len' must be one of defined strings.
470             String: %s
471             Possible strings: 5
472             Parameter 'status' must be one of defined strings.
473             String: %s
474             Possible strings: a c d n p
475             Parameter 'subfield_code_count' must be one of defined strings.
476             String: %s
477             Possible strings: 2
478             Parameter 'type' must be one of defined strings.
479             String: %s
480             Possible strings: a c d e f g i j k m o p r t
481             Parameter 'type_of_control' must be one of defined strings.
482             String: %s
483             Possible strings: ' ' a
484             Parameter 'undefined' must be one of defined strings.
485             String: %s
486             Possible strings: 0
487              
488             =head1 EXAMPLE
489              
490             =for comment filename=create_and_dump_marc_leader.pl
491              
492             use strict;
493             use warnings;
494              
495             use Data::Printer;
496             use Data::MARC::Leader;
497              
498             my $obj = Data::MARC::Leader->new(
499             'bibliographic_level' => 'm',
500             'char_coding_scheme' => 'a',
501             'data_base_addr' => 541,
502             'descriptive_cataloging_form' => 'i',
503             'encoding_level' => ' ',
504             'impl_def_portion_len' => '0',
505             'indicator_count' => '2',
506             'length' => 2200,
507             'length_of_field_portion_len' => '4',
508             'multipart_resource_record_level' => ' ',
509             'raw' => '02200cem a2200541 i 4500',
510             'starting_char_pos_portion_len' => '5',
511             'status' => 'c',
512             'subfield_code_count' => '2',
513             'type' => 'e',
514             'type_of_control' => ' ',
515             'undefined' => '0',
516             );
517              
518             # Print out.
519             p $obj;
520              
521             # Output:
522             # Data::MARC::Leader {
523             # parents: Mo::Object
524             # public methods (3):
525             # BUILD
526             # Mo::utils:
527             # check_strings
528             # Readonly:
529             # Readonly
530             # private methods (0)
531             # internals: {
532             # bibliographic_level "m",
533             # char_coding_scheme "a",
534             # data_base_addr 541,
535             # descriptive_cataloging_form "i",
536             # encoding_level " ",
537             # impl_def_portion_len 0,
538             # indicator_count 2,
539             # length 2200,
540             # length_of_field_portion_len 4,
541             # multipart_resource_record_level " ",
542             # raw "02200cem a2200541 i 4500",
543             # starting_char_pos_portion_len 5,
544             # status "c",
545             # subfield_code_count 2,
546             # type "e",
547             # type_of_control " ",
548             # undefined 0
549             # }
550             # }
551              
552             =head1 DEPENDENCIES
553              
554             L<Mo>,
555             L<Mo::utils>,
556             L<Readonly>.
557              
558             =head1 REPOSITORY
559              
560             L<https://github.com/michal-josef-spacek/Data-MARC-Leader>
561              
562             =head1 AUTHOR
563              
564             Michal Josef Špaček L<mailto:skim@cpan.org>
565              
566             L<http://skim.cz>
567              
568             =head1 LICENSE AND COPYRIGHT
569              
570             © 2023-2025 Michal Josef Špaček
571              
572             BSD 2-Clause License
573              
574             =head1 ACKNOWLEDGEMENTS
575              
576             Development of this software has been made possible by institutional support
577             for the long-term strategic development of the National Library of the Czech
578             Republic as a research organization provided by the Ministry of Culture of
579             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
580              
581             =head1 VERSION
582              
583             0.07
584              
585             =cut