File Coverage

blib/lib/Data/MARC/Field008/Map.pm
Criterion Covered Total %
statement 41 43 95.3
branch 2 6 33.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 51 58 87.9


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::Map;
2              
3 10     10   220398 use strict;
  10         24  
  10         498  
4 10     10   105 use warnings;
  10         20  
  10         751  
5              
6 10         340 use Data::MARC::Field008::Utils qw(check_government_publication check_index
7             check_item_form check_map_cartographic_material_type check_map_projection
8 10     10   6539 check_map_relief check_map_special_format);
  10         45  
9 10     10   2889 use Error::Pure qw(err);
  10         273  
  10         668  
10 10     10   86 use Error::Pure::Utils qw(clean err_get);
  10         21  
  10         223  
11 10     10   6314 use Mo qw(build is);
  10         6898  
  10         58  
12 10     10   25800 use Mo::utils 0.22 qw(check_length_fix);
  10         33974  
  10         281  
13              
14             our $STRICT = 1;
15              
16             our $VERSION = 0.04;
17              
18             has form_of_item => (
19             is => 'ro',
20             );
21              
22             has government_publication => (
23             is => 'ro',
24             );
25              
26             has index => (
27             is => 'ro',
28             );
29              
30             has projection => (
31             is => 'ro',
32             );
33              
34             has raw => (
35             is => 'ro',
36             );
37              
38             has relief => (
39             is => 'ro',
40             );
41              
42             has special_format_characteristics => (
43             is => 'ro',
44             );
45              
46             has type_of_cartographic_material => (
47             is => 'ro',
48             );
49              
50             sub BUILD {
51 10     10 0 2904934 my $self = shift;
52              
53             # Check 'raw'
54 10         66 check_length_fix($self, 'raw', 17);
55              
56             # Check 'form_of_item'.
57 9         182 eval { check_item_form($self, 'form_of_item'); };
  9         63  
58              
59             # Check 'government_publication'.
60 9         20 eval { check_government_publication($self, 'government_publication'); };
  9         43  
61              
62             # Check 'index'.
63 9         22 eval { check_index($self, 'index'); };
  9         38  
64              
65             # Check 'projection'.
66 9         40 eval { check_map_projection($self, 'projection'); };
  9         55  
67              
68             # Check 'relief'.
69 9         24 eval { check_map_relief($self, 'relief'); };
  9         38  
70              
71             # Check 'special_format_characteristics'.
72 9         18 eval { check_map_special_format($self, 'special_format_characteristics'); };
  9         55  
73              
74             # Check 'type_of_cartographic_material'.
75 9         25 eval { check_map_cartographic_material_type($self, 'type_of_cartographic_material'); };
  9         34  
76              
77 9 50       35 if ($STRICT) {
78 9         58 my @errors = err_get();
79 9 50       121 if (@errors) {
80 0 0       0 err "Couldn't create data object of map.",
81             defined $self->raw ? ('Raw string', $self->raw) : (),
82             ;
83             }
84             } else {
85 0         0 clean();
86             }
87              
88 9         43 return;
89             }
90              
91             1;
92              
93             __END__
94              
95             =pod
96              
97             =encoding utf8
98              
99             =head1 NAME
100              
101             Data::MARC::Field008::Map - Data object for MARC field 008 map material.
102              
103             =head1 SYNOPSIS
104              
105             use Data::MARC::Field008::Map;
106              
107             my $obj = Data::MARC::Field008::Map->new(%params);
108             my $form_of_item = $obj->form_of_item;
109             my $government_publication = $obj->government_publication;
110             my $index = $obj->index;
111             my $projection = $obj->projection;
112             my $raw = $obj->raw;
113             my $relief = $obj->relief;
114             my $special_format_characteristics = $obj->special_format_characteristics;
115             my $type_of_cartographic_material = $obj->type_of_cartographic_material;
116              
117             =head1 METHODS
118              
119             =head2 C<new>
120              
121             my $obj = Data::MARC::Field008::Map->new(%params);
122              
123             Constructor.
124              
125             =over 8
126              
127             =item * C<form_of_item>
128              
129             Form of item. The length of the string is 1 character.
130             Possible characters are ' ', 'a', 'b', 'c', 'd', 'f', 'o', 'q', 's', 'u', 'z' or '|'.
131              
132             It's required.
133              
134             Default value is undef.
135              
136             =item * C<government_publication>
137              
138             Government publication. The length of the string is 1 character.
139             Possible characters are ' ', 'a', 'c', 'f', 'i', 'l', 'm', 'o', 's', 'u', 'z' or '|'.
140              
141             It's required.
142              
143             Default value is undef.
144              
145             =item * C<index>
146              
147             Index. The length of the string is 1 character.
148             Possible characters are '0', '1' or '|'.
149              
150             It's required.
151              
152             Default value is undef.
153              
154             =item * C<projection>
155              
156             Projection. The length of the string is 2 characters.
157             Possible strings are ' ', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'am', 'an',
158             'ap', 'au', 'az', 'ba', 'bb', 'bc', 'bd', 'be', 'be', 'bf', 'bg', 'bh', 'bi',
159             'bj', 'bk', 'bl', 'bo', 'br', 'bs', 'bu', 'bz', 'ca', 'cb', 'cc', 'ce', 'cp',
160             'cu', 'cz', 'da', 'db', 'dc', 'dd', 'de', 'df', 'dg', 'dh', 'dl', 'zz' or '||'.
161              
162             It's required.
163              
164             Default value is undef.
165              
166             =item * C<raw>
167              
168             Raw string of material. The length of the string is 17 characters.
169              
170             It's optional.
171              
172             Default value is undef.
173              
174             =item * C<relief>
175              
176             Map relief. The length of the string is 4 characters.
177             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j', 'k', 'm' or 'z' in each character.
178             Or '||||' in all 4 characters.
179              
180             It's required.
181              
182             Default value is undef.
183              
184             =item * C<special_format_characteristics>
185              
186             Special format characteristics. The length of the string is 2 characters.
187             Possible characters are ' ', 'e', 'j', 'k', 'l', 'n', 'o', 'p', 'r' or 'z'.
188             Or '||' in all 2 characters.
189              
190             It's required.
191              
192             Default value is undef.
193              
194             =item * C<type_of_cartographic_material>
195              
196             Type of cartographic material. The length of the string is 1 character.
197             Possible characters are 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'u', 'z' or '|'.
198              
199             It's required.
200              
201             Default value is undef.
202              
203             =back
204              
205             Returns instance of object.
206              
207             =head2 C<form_of_item>
208              
209             my $form_of_item = $obj->form_of_item;
210              
211             Get form of item.
212              
213             Returns string.
214              
215             =head2 C<government_publication>
216              
217             my $government_publication = $obj->government_publication;
218              
219             Get governent publication.
220              
221             Returns string.
222              
223             =head2 C<index>
224              
225             my $index = $obj->index;
226              
227             Get index.
228              
229             Returns string.
230              
231             =head2 C<projection>
232              
233             my $projection = $obj->projection;
234              
235             Get projection.
236              
237             Returns string.
238              
239             =head2 C<raw>
240              
241             my $raw = $obj->raw;
242              
243             Get raw string of the block.
244              
245             Returns string.
246              
247             =head2 C<relief>
248              
249             my $relief = $obj->relief;
250              
251             Get relief.
252              
253             Returns string.
254              
255             =head2 C<special_format_characteristics>
256              
257             my $special_format_characteristics = $obj->special_format_characteristics;
258              
259             Get special format characteristics.
260              
261             Returns string.
262              
263             =head2 C<type_of_cartographic_material>
264              
265             my $type_of_cartographic_material = $obj->type_of_cartographic_material;
266              
267             Get type of cartographic material.
268              
269             Returns string.
270              
271             =head1 ERRORS
272              
273             new():
274             Couldn't create data object of map.
275             Raw string: %s
276             Parameter 'raw' has length different than '17'.
277             Value: %s
278             From Data::MARC::Field008::Utils::check_government_publication():
279             Parameter 'government_publication' has bad value.
280             Value: %s
281             Parameter 'government_publication' is required.
282             Parameter 'government_publication' length is bad.
283             Length: %s
284             Value: %s
285             Expected length: 1
286             Parameter 'government_publication' must be a scalar value.
287             Reference: %s
288             From Data::MARC::Field008::Utils::check_index():
289             Parameter 'index' has bad value.
290             Value: %s
291             Parameter 'index' is required.
292             Parameter 'index' length is bad.
293             Length: %s
294             Value: %s
295             Expected length: 1
296             Parameter 'index' must be a scalar value.
297             Reference: %s
298             From Data::MARC::Field008::Utils::check_item_form():
299             Parameter 'form_of_item' has bad value.
300             Value: %s
301             Parameter 'form_of_item' is required.
302             Parameter 'form_of_item' length is bad.
303             Length: %s
304             Value: %s
305             Expected length: 1
306             Parameter 'form_of_item' must be a scalar value.
307             Reference: %s
308             From Data::MARC::Field008::Utils::check_map_cartographic_material_type():
309             Parameter 'type_of_cartographic_material' has bad value.
310             Value: %s
311             Parameter 'type_of_cartographic_material' is required.
312             Parameter 'type_of_cartographic_material' length is bad.
313             Length: %s
314             Value: %s
315             Expected length: 1
316             Parameter 'type_of_cartographic_material' must be a scalar value.
317             Reference: %s
318             From Data::MARC::Field008::Utils::check_map_projection():
319             Parameter 'projection' has bad value.
320             Value: %s
321             Parameter 'projection' is required.
322             Parameter 'projection' length is bad.
323             Length: %s
324             Value: %s
325             Expected length: 2
326             Parameter 'projection' must be a scalar value.
327             Reference: %s
328             From Data::MARC::Field008::Utils::check_map_relief():
329             Parameter 'relief' contains bad relief character.
330             Value: %s
331             Parameter 'relief' has value with pipe character.
332             Value: %s
333             Parameter 'relief' is required.
334             Parameter 'relief' length is bad.
335             Length: %s
336             Value: %s
337             Expected length: 4
338             Parameter 'relief' must be a scalar value.
339             Reference: %s
340             From Data::MARC::Field008::Utils::check_map_special_format():
341             Parameter 'special_format_characteristics' contains bad special format characteristics character.
342             Value: %s
343             Parameter 'special_format_characteristics' has value with pipe character.
344             Value: %s
345             Parameter 'special_format_characteristics' is required.
346             Parameter 'special_format_characteristics' length is bad.
347             Length: %s
348             Value: %s
349             Expected length: 2
350             Parameter 'special_format_characteristics' must be a scalar value.
351             Reference: %s
352              
353             =head1 EXAMPLE
354              
355             =for comment filename=create_and_dump_marc_field_008_map_material.pl
356              
357             use strict;
358             use warnings;
359              
360             use Data::Printer;
361             use Data::MARC::Field008::Map;
362              
363             # cnb000001006
364             my $obj = Data::MARC::Field008::Map->new(
365             'form_of_item' => ' ',
366             'government_publication' => ' ',
367             'index' => '1',
368             'projection' => ' ',
369             # 89012345678901234
370             'raw' => 'z e 1 ',
371             'relief' => 'z ',
372             'special_format_characteristics' => ' ',
373             'type_of_cartographic_material' => 'e',
374             );
375              
376             # Print out.
377             p $obj;
378              
379             # Output:
380             # Data::MARC::Field008::Map {
381             # parents: Mo::Object
382             # public methods (11):
383             # BUILD
384             # Data::MARC::Field008::Utils:
385             # check_government_publication, check_index, check_item_form, check_map_cartographic_material_type, check_map_projection, check_map_relief, check_map_special_format
386             # Error::Pure:
387             # err
388             # Error::Pure::Utils:
389             # err_get
390             # Mo::utils:
391             # check_length_fix
392             # private methods (0)
393             # internals: {
394             # form_of_item " ",
395             # government_publication " ",
396             # index 1,
397             # projection " ",
398             # raw "z e 1 ",
399             # relief "z ",
400             # special_format_characteristics " ",
401             # type_of_cartographic_material "e"
402             # }
403             # }
404              
405             =head1 DEPENDENCIES
406              
407             L<Data::MARC::Field008::Utils>,
408             L<Error::Pure>
409             L<Error::Pure::Utils>
410             L<Mo>,
411             L<Mo::utils>.
412              
413             =head1 REPOSITORY
414              
415             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
416              
417             =head1 AUTHOR
418              
419             Michal Josef Špaček L<mailto:skim@cpan.org>
420              
421             L<http://skim.cz>
422              
423             =head1 LICENSE AND COPYRIGHT
424              
425             © 2025 Michal Josef Špaček
426              
427             BSD 2-Clause License
428              
429             =head1 ACKNOWLEDGEMENTS
430              
431             Development of this software has been made possible by institutional support
432             for the long-term strategic development of the National Library of the Czech
433             Republic as a research organization provided by the Ministry of Culture of
434             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
435              
436             =head1 VERSION
437              
438             0.04
439              
440             =cut