File Coverage

blib/lib/Data/MARC/Field008/ComputerFile.pm
Criterion Covered Total %
statement 37 37 100.0
branch 6 6 100.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 51 52 98.0


line stmt bran cond sub pod time code
1             package Data::MARC::Field008::ComputerFile;
2              
3 7     7   129910 use strict;
  7         15  
  7         308  
4 7     7   38 use warnings;
  7         10  
  7         459  
5              
6 7         232 use Data::MARC::Field008::Utils qw(check_computer_file_item_form
7             check_computer_file_type check_government_publication
8 7     7   4595 check_target_audience);
  7         61  
9 7     7   2131 use Error::Pure qw(err);
  7         15  
  7         407  
10 7     7   70 use Error::Pure::Utils qw(clean err_get);
  7         17  
  7         158  
11 7     7   4460 use Mo qw(build is);
  7         4847  
  7         44  
12 7     7   16542 use Mo::utils 0.22 qw(check_length_fix check_required);
  7         21935  
  7         1473  
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 raw => (
27             is => 'ro',
28             );
29              
30             has target_audience => (
31             is => 'ro',
32             );
33              
34             has type_of_computer_file => (
35             is => 'ro',
36             );
37              
38             sub BUILD {
39 8     8 0 2040916 my $self = shift;
40              
41             # Check 'raw'
42 8         52 check_length_fix($self, 'raw', 17);
43              
44             # Check 'form_of_item'.
45 8         157 eval { check_computer_file_item_form($self, 'form_of_item'); };
  8         45  
46              
47             # Check 'government_publication'.
48 8         6845 eval { check_government_publication($self, 'government_publication'); };
  8         41  
49              
50             # Check 'target_audience'.
51 8         1378 eval { check_target_audience($self, 'target_audience'); };
  8         30  
52              
53             # Check 'type_of_computer_file'.
54 8         1434 eval { check_computer_file_type($self, 'type_of_computer_file'); };
  8         57  
55              
56 8 100       1471 if ($STRICT) {
57 7         52 my @errors = err_get();
58 7 100       80 if (@errors) {
59 2 100       12 err "Couldn't create data object of computer file.",
60             defined $self->raw ? ('Raw string', $self->raw) : (),
61             ;
62             }
63             } else {
64 1         5 clean();
65             }
66              
67 6         31 return;
68             }
69              
70             1;
71              
72             __END__
73              
74             =pod
75              
76             =encoding utf8
77              
78             =head1 NAME
79              
80             Data::MARC::Field008::ComputerFile - Data object for MARC field 008 computer file material.
81              
82             =head1 SYNOPSIS
83              
84             use Data::MARC::Field008::ComputerFile;
85              
86             my $obj = Data::MARC::Field008::ComputerFile->new(%params);
87             my $form_of_item = $obj->form_of_item;
88             my $government_publication = $obj->government_publication;
89             my $raw = $obj->raw;
90             my $target_audience = $obj->target_audience;
91             my $type_of_computer_file = $obj->type_of_computer_file;
92              
93             =head1 METHODS
94              
95             =head2 C<new>
96              
97             my $obj = Data::MARC::Field008::ComputerFile->new(%params);
98              
99             Constructor.
100              
101             =over 8
102              
103             =item * C<form_of_item>
104              
105             Form of item. The length of the item is 1 character.
106             Possible characters are ' ', 'o', 'q' or '|'.
107              
108             It's required.
109              
110             Default value is undef.
111              
112             =item * C<government_publication>
113              
114             Government publication. The length of the string is 1 character.
115             Possible characters are ' ', 'a', 'c', 'f', 'i', 'l', 'm', 'o', 's', 'u', 'z' or '|'.
116              
117             It's required.
118              
119             Default value is undef.
120              
121             =item * C<raw>
122              
123             Raw string of material. The length of the string is 17 characters.
124              
125             It's optional.
126              
127             Default value is undef.
128              
129             =item * C<target_audience>
130              
131             Target audience. The length of the item is 1 character.
132             Possible characters are ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'j' or '|'.
133              
134             It's required.
135              
136             Default value is undef.
137              
138             =item * C<type_of_computer_file>
139              
140             Type of computer file. The length of the item is 1 character.
141             Possible characters are 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'm',
142             'u', 'z' or '|'.
143              
144             It's required.
145              
146             Default value is undef.
147              
148             =back
149              
150             Returns instance of object.
151              
152             =head2 C<form_of_item>
153              
154             my $form_of_item = $obj->form_of_item;
155              
156             Get form of item.
157              
158             Returns string.
159              
160             =head2 C<government_publication>
161              
162             my $government_publication = $obj->government_publication;
163              
164             Get government publication.
165              
166             Returns string.
167              
168             =head2 C<raw>
169              
170             my $raw = $obj->form_of_item;
171              
172             Get raw string of the block.
173              
174             Returns string.
175              
176             =head2 C<target_audience>
177              
178             my $target_audience = $obj->target_audience;
179              
180             Get target audience.
181              
182             Returns string.
183              
184             =head2 C<type_of_computer_file>
185              
186             my $type_of_computer_file = $obj->type_of_computer_file;
187              
188             Get type of computer file.
189              
190             Returns string.
191              
192             =head1 ERRORS
193              
194             new():
195             Couldn't create data object of computer file.
196             Raw string: %s
197             Parameter 'raw' has length different than '17'.
198             Value: %s
199             From Data::MARC::Field008::Utils::check_computer_file_item_form():
200             Parameter 'form_of_item' has bad value.
201             Value: %s
202             Parameter 'form_of_item' is required.
203             Parameter 'form_of_item' length is bad.
204             Length: %s
205             Value: %s
206             Expected length: 1
207             Parameter 'form_of_item' must be a scalar value.
208             Reference: %s
209             From Data::MARC::Field008::Utils::check_computer_file_type():
210             Parameter 'type_of_computer_file' has bad value.
211             Value: %s
212             Parameter 'type_of_computer_file' is required.
213             Parameter 'type_of_computer_file' length is bad.
214             Length: %s
215             Value: %s
216             Expected length: 1
217             Parameter 'type_of_computer_file' must be a scalar value.
218             Reference: %s
219             From Data::MARC::Field008::Utils::check_government_publication():
220             Parameter 'government_publication' has bad value.
221             Value: %s
222             Parameter 'government_publication' is required.
223             Parameter 'government_publication' length is bad.
224             Length: %s
225             Value: %s
226             Expected length: 1
227             Parameter 'government_publication' must be a scalar value.
228             Reference: %s
229             From Data::MARC::Field008::Utils::check_target_audience():
230             Parameter 'target_audience' has bad value.
231             Value: %s
232             Parameter 'target_audience' is required.
233             Parameter 'target_audience' length is bad.
234             Length: %s
235             Value: %s
236             Expected length: 1
237             Parameter 'target_audience' must be a scalar value.
238             Reference: %s
239              
240             =head1 EXAMPLE
241              
242             =for comment filename=create_and_dump_marc_field_008_computer_file_material.pl
243              
244             use strict;
245             use warnings;
246              
247             use Data::Printer;
248             use Data::MARC::Field008::ComputerFile;
249              
250             # cnb000208289
251             my $obj = Data::MARC::Field008::ComputerFile->new(
252             'form_of_item' => ' ',
253             'government_publication' => ' ',
254             # 89012345678901234
255             'raw' => ' m ',
256             'target_audience' => ' ',
257             'type_of_computer_file' => 'm',
258             );
259              
260             # Print out.
261             p $obj;
262              
263             # Output:
264             # Data::MARC::Field008::ComputerFile {
265             # parents: Mo::Object
266             # public methods (9):
267             # BUILD
268             # Data::MARC::Field008::Utils:
269             # check_computer_file_item_form, check_computer_file_type, check_government_publication, check_target_audience
270             # Error::Pure:
271             # err
272             # Error::Pure::Utils:
273             # err_get
274             # Mo::utils:
275             # check_length_fix, check_required
276             # private methods (0)
277             # internals: {
278             # form_of_item " ",
279             # government_publication " ",
280             # raw " m ",
281             # target_audience " ",
282             # type_of_computer_file "m"
283             # }
284             # }
285              
286             =head1 DEPENDENCIES
287              
288             L<Data::MARC::Field008::Utils>,
289             L<Error::Pure>
290             L<Error::Pure::Utils>
291             L<Mo>,
292             L<Mo::utils>.
293              
294             =head1 REPOSITORY
295              
296             L<https://github.com/michal-josef-spacek/Data-MARC-Field008>
297              
298             =head1 AUTHOR
299              
300             Michal Josef Špaček L<mailto:skim@cpan.org>
301              
302             L<http://skim.cz>
303              
304             =head1 LICENSE AND COPYRIGHT
305              
306             © 2025 Michal Josef Špaček
307              
308             BSD 2-Clause License
309              
310             =head1 ACKNOWLEDGEMENTS
311              
312             Development of this software has been made possible by institutional support
313             for the long-term strategic development of the National Library of the Czech
314             Republic as a research organization provided by the Ministry of Culture of
315             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
316              
317             =head1 VERSION
318              
319             0.04
320              
321             =cut