File Coverage

blib/lib/Data/MARC/Validator/Report.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Data::MARC::Validator::Report;
2              
3 5     5   168293 use strict;
  5         11  
  5         222  
4 5     5   44 use warnings;
  5         9  
  5         302  
5              
6 5     5   2241 use Mo qw(build default is);
  5         5279  
  5         26  
7 5     5   15596 use Mo::utils 0.08 qw(check_isa check_required);
  5         93586  
  5         130  
8 5     5   3804 use Mo::utils::Array qw(check_array_object);
  5         16800  
  5         167  
9              
10             our $VERSION = 0.02;
11              
12             has datetime => (
13             is => 'ro',
14             );
15              
16             has plugins => (
17             default => [],
18             is => 'ro',
19             );
20              
21             sub BUILD {
22 4     4 0 2801628 my $self = shift;
23              
24             # Check 'datetime'.
25 4         28 check_required($self, 'datetime');
26 4         70 check_isa($self, 'datetime', 'DateTime');
27              
28             # Check 'plugins'.
29 4         167 check_array_object($self, 'plugins', 'Data::MARC::Validator::Report::Plugin');
30              
31 4         61 return;
32             }
33              
34             1;
35              
36             __END__
37              
38             =pod
39              
40             =encoding utf8
41              
42             =head1 NAME
43              
44             Data::MARC::Validator::Report - Data object for MARC validator report.
45              
46             =head1 SYNOPSIS
47              
48             use Data::MARC::Validator::Report;
49              
50             my $obj = Data::MARC::Validator::Report->new(%params);
51             my $datetime = $obj->datetime;
52             my $plugins_ar = $obj->plugins;
53              
54             =head1 METHODS
55              
56             =head2 C<new>
57              
58             my $obj = Data::MARC::Validator::Report->new(%params);
59              
60             Constructor.
61              
62             =over 8
63              
64             =item * C<datetime>
65              
66             Datetime of report. Must be a L<DataTime> instance.
67              
68             Parameter is required.
69              
70             =item * C<plugins>
71              
72             List of plugins data objects. Each one must be a
73             L<Data::MARC::Validator::Report::Plugin> instance.
74              
75             Default value is [].
76              
77             =back
78              
79             Returns instance of object.
80              
81             =head2 C<datetime>
82              
83             my $datetime = $obj->datetime;
84              
85             Get datetime of report.
86              
87             Returns L<DateTime> object.
88              
89             =head2 C<plugins>
90              
91             my $plugins_ar = $obj->plugins;
92              
93             Get plugin reports.
94              
95             Return reference to array with L<Data::MARC::Validator::Report::Plugin> objects.
96              
97             =head1 ERRORS
98              
99             new():
100             From Mo::utils:
101             Parameter 'datetime' is required.
102             Parameter 'datetime' must be a 'DateTime' object.
103             Value: %s
104             Reference: %s
105              
106             From Mo::utils::Array:
107             Parameter 'plugins' must be a array.
108             Value: %s
109             Reference: %s
110             Parameter 'plugins' with array must contain 'Data::MARC::Validator::Report::Plugin' objects.
111             Value: %s
112             Reference: %s
113              
114              
115             =head1 EXAMPLE
116              
117             =for comment filename=create_and_dump_validator_report.pl
118              
119             use strict;
120             use warnings;
121              
122             use Data::Printer;
123             use Data::MARC::Validator::Report;
124             use Data::MARC::Validator::Report::Error;
125             use Data::MARC::Validator::Report::Errors;
126             use Data::MARC::Validator::Report::Plugin;
127             use DateTime;
128              
129             # Create data object for validator report.
130             my $report = Data::MARC::Validator::Report->new(
131             'datetime' => DateTime->now,
132             'plugins' => [
133             Data::MARC::Validator::Report::Plugin->new(
134             'errors' => [
135             Data::MARC::Validator::Report::Errors->new(
136             'errors' => [
137             Data::MARC::Validator::Report::Error->new(
138             'error' => 'Error #1',
139             'params' => {
140             'key' => 'value',
141             },
142             ),
143             Data::MARC::Validator::Report::Error->new(
144             'error' => 'Error #2',
145             'params' => {
146             'key' => 'value',
147             },
148             ),
149             ],
150             'filters' => ['filter1', 'filter2'],
151             'record_id' => 'id1',
152             ),
153             ],
154             'module_name' => 'MARC::Validator::Plugin::Foo',
155             'name' => 'foo',
156             'version' => '0.01',
157             ),
158             ],
159             );
160              
161             # Dump out.
162             p $report;
163              
164             # Output:
165             # Data::MARC::Validator::Report {
166             # parents: Mo::Object
167             # public methods (4):
168             # BUILD
169             # Mo::utils:
170             # check_isa, check_required
171             # Mo::utils::Array:
172             # check_array_object
173             # private methods (0)
174             # internals: {
175             # datetime 2026-02-22T11:16:24 (DateTime),
176             # plugins [
177             # [0] Data::MARC::Validator::Report::Plugin
178             # ]
179             # }
180             # }
181              
182             =head1 DEPENDENCIES
183              
184             L<Mo>,
185             L<Mo::utils>,
186             L<Mo::utils::Array>.
187              
188             =head1 REPOSITORY
189              
190             L<https://github.com/michal-josef-spacek/Data-MARC-Validator-Report>
191              
192             =head1 AUTHOR
193              
194             Michal Josef Špaček L<mailto:skim@cpan.org>
195              
196             L<http://skim.cz>
197              
198             =head1 LICENSE AND COPYRIGHT
199              
200             © 2025-2025 Michal Josef Špaček
201              
202             BSD 2-Clause License
203              
204             =head1 ACKNOWLEDGEMENTS
205              
206             Development of this software has been made possible by institutional support
207             for the long-term strategic development of the National Library of the Czech
208             Republic as a research organization provided by the Ministry of Culture of
209             the Czech Republic (DKRVO 2024–2028), Area 11: Linked Open Data.
210              
211             =head1 VERSION
212              
213             0.02
214              
215             =cut