Object.pm

filter: Statementstmt 96.8% 93 / 96 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 91.6% 11 / 12 Podpod 50.0% 1 / 2 totaltotal 88.7% 110 / 124 CC 7 SCAR 10.5
CC
7
Cov
92%
BUILD
6.2
full_name
2.0
__ANON__
1.2
CRAP 2.9
« Object/Series.pm ↑ Summary Object/PublicationDate.pm »
1 package MARC::Convert::Wikidata::Object;
2  
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 33 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use List::Util 1.33 qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 33 ▶use Mo qw(build default is);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 33 ▶use Mo::utils 0.26 qw(check_isa check_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 33 ▶use Mo::utils::Array qw(check_array check_array_object);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 33 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 33 Readonly::Array our @COVERS => qw(hardback paperback);
14  
15 33 our $VERSION = 0.16;
16  
17 33 has authors => (
18 default => [],
19 is => 'ro',
20 );
21  
22 33 has authors_of_afterword => (
23 default => [],
24 is => 'ro',
25 );
26  
27 33 has authors_of_introduction => (
28 default => [],
29 is => 'ro',
30 );
31  
32 33 has compilers => (
33 default => [],
34 is => 'ro',
35 );
36  
37 33 has cover => (
38 is => 'ro',
39 );
40  
41 33 has covers => (
42 default => [],
43 is => 'ro',
44 );
45  
46 33 has cycles => (
47 default => [],
48 is => 'ro',
49 );
50  
51 33 has directors => (
52 default => [],
53 is => 'ro',
54 );
55  
56 33 has dml => (
57 is => 'ro',
58 );
59  
60 33 has edition_number => (
61 is => 'ro',
62 );
63  
64 33 has edition_of_work => (
65 is => 'ro',
66 );
67  
68 33 has editors => (
69 default => [],
70 is => 'ro',
71 );
72  
73 33 has end_time => (
74 is => 'ro',
75 );
76  
77 33 has external_ids => (
78 default => [],
79 is => 'ro',
80 );
81  
82 33 has illustrators => (
83 default => [],
84 is => 'ro',
85 );
86  
87 33 has isbns => (
88 default => [],
89 is => 'ro',
90 );
91  
92 33 has issn => (
93 is => 'ro',
94 );
95  
96 33 has languages => (
97 default => [],
98 is => 'ro',
99 );
100  
101 33 has krameriuses => (
102 default => [],
103 is => 'ro',
104 );
105  
106 33 has narrators => (
107 default => [],
108 is => 'ro',
109 );
110  
111 33 has number_of_pages => (
112 is => 'ro',
113 );
114  
115 33 has photographers => (
116 default => [],
117 is => 'ro',
118 );
119  
120 33 has publication_date => (
121 is => 'ro',
122 );
123  
124 33 has publishers => (
125 default => [],
126 is => 'ro',
127 );
128  
129 33 has series => (
130 default => [],
131 is => 'ro',
132 );
133  
134 33 has start_time => (
135 is => 'ro',
136 );
137  
138 33 has subtitles => (
139 default => [],
140 is => 'ro',
141 );
142  
143 33 has title => (
144 is => 'ro',
145 );
146  
147 33 has translators => (
148 default => [],
149 is => 'ro',
150 );
151  
152 33 has udcs => (
153 default => [],
154 is => 'ro',
155 );
156  
157 4 ▶sub full_name {
Subroutine full_name: called CC=2 SCAR=6.9
Pod documented
158 4 my $self = shift;
159  
160 4 my $full_name = $self->title;
161 4 foreach my $subtitle (@{$self->subtitles}) {
162 3 $full_name .= ': '.$subtitle;
163 }
164  
165 4 return $full_name;
166 }
167  
168 67 ▶sub BUILD {
Subroutine BUILD: called CC=6 SCAR=18.3
Pod undocumented
169 67 my $self = shift;
170  
171 # Check 'authors'.
172 67 check_array_object($self, 'authors', 'MARC::Convert::Wikidata::Object::People');
173  
174 # Check 'authors_of_introduction'.
175 67 check_array_object($self, 'authors_of_afterword', 'MARC::Convert::Wikidata::Object::People');
176  
177 # Check 'authors_of_introduction'.
178 67 check_array_object($self, 'authors_of_introduction', 'MARC::Convert::Wikidata::Object::People');
179  
180 # Check 'compilers'.
181 67 check_array_object($self, 'compilers', 'MARC::Convert::Wikidata::Object::People');
182  
183 # Check 'cover'.
184 67 ▶ if (defined $self->{'cover'} && none { $_ eq $self->{'cover'} } @COVERS) {
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"cover"} and &none(sub { $_ eq $self->{"cover"}; } , @MARC::Convert::Wikidata::Object::COVERS)) 0 67 67
Condition66%2/3
defined $self->{"cover"} and &none(sub { $_ eq $self->{"cover"}; } , @MARC::Convert::Wikidata::Object::COVERS)
!ll&&!rl&&r
6610
MC/DC0%0/2
defined $self->{"cover"} and &none(sub { $_ eq $self->{"cover"}; } , @MARC::Convert::Wikidata::Object::COVERS)
defined $self->{"cover"} &none(sub { $_ eq $self->{"cover"}; } , @MARC::Convert::Wikidata::Object::COVERS)
Truth table66%2/3
A and B
A= defined $self->{"cover"}B= &none(sub { $_ eq $self->{"cover"}; } , @MARC::Convert::Wikidata::Object::COVERS)
ABresult
0X0
100
111
185 0 err "Book cover '".$self->{'cover'}."' doesn't exist.";
186 }
187  
188 # Check 'covers'.
189 # XXX Common check.
190 67 foreach my $cover (@{$self->covers}) {
191 0 ▶ if (! defined $cover && none { $_ eq $cover } @COVERS) {
Subroutine __ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $cover and &none(sub { $_ eq $cover; } , @MARC::Convert::Wikidata::Object::COVERS)) 0 2 2
Condition33%1/3
not defined $cover and &none(sub { $_ eq $cover; } , @MARC::Convert::Wikidata::Object::COVERS)
!ll&&!rl&&r
200
MC/DC0%0/2
not defined $cover and &none(sub { $_ eq $cover; } , @MARC::Convert::Wikidata::Object::COVERS)
not defined $cover &none(sub { $_ eq $cover; } , @MARC::Convert::Wikidata::Object::COVERS)
Truth table33%1/3
not(A) and B
A= not defined $coverB= &none(sub { $_ eq $cover; } , @MARC::Convert::Wikidata::Object::COVERS)
ABresult
0X0
100
111
192 0 err "Book cover '".$cover."' doesn't exist.";
193 }
194 }
195  
196 # Check 'cycles'.
197 67 check_array_object($self, 'cycles', 'MARC::Convert::Wikidata::Object::Series');
198  
199 # Check 'directors'.
200 67 check_array_object($self, 'directors', 'MARC::Convert::Wikidata::Object::People');
201  
202 # Check 'dml',
203 67 check_number($self, 'dml');
204  
205 # Check 'edition_of_work'.
206 67 check_isa($self, 'edition_of_work', 'MARC::Convert::Wikidata::Object::Work');
207  
208 # Check 'editors'.
209 67 check_array_object($self, 'editors', 'MARC::Convert::Wikidata::Object::People');
210  
211 # Check 'end_time'.
212 67 check_number($self, 'end_time');
213  
214 # Check 'external_ids'.
215 67 check_array_object($self, 'external_ids', 'MARC::Convert::Wikidata::Object::ExternalId');
216  
217 # Check 'illustrators'.
218 67 check_array_object($self, 'illustrators', 'MARC::Convert::Wikidata::Object::People');
219  
220 # Check 'isbns'.
221 67 check_array_object($self, 'isbns', 'MARC::Convert::Wikidata::Object::ISBN');
222  
223 # Check 'languages'.
224 67 check_array($self, 'languages');
225  
226 # Check 'krameriues'.
227 67 check_array_object($self, 'krameriuses', 'MARC::Convert::Wikidata::Object::Kramerius');
228  
229 # Check 'narrators'.
230 67 check_array_object($self, 'narrators', 'MARC::Convert::Wikidata::Object::People');
231  
232 # Check 'photographers'.
233 67 check_array_object($self, 'photographers', 'MARC::Convert::Wikidata::Object::People');
234  
235 # Check 'publishers'.
236 67 check_array_object($self, 'publishers', 'MARC::Convert::Wikidata::Object::Publisher');
237  
238 # Check 'series'.
239 67 check_array_object($self, 'series', 'MARC::Convert::Wikidata::Object::Series');
240  
241 # Check 'start_time'.
242 67 check_number($self, 'start_time');
243  
244 # Check 'subtitles'.
245 67 check_array($self, 'subtitles');
246  
247 # Check 'translators'.
248 67 check_array_object($self, 'translators',
249 'MARC::Convert::Wikidata::Object::People', 'Translator');
250  
251 # Check 'udcs'.
252 67 check_array($self, 'udcs');
253 # TODO UDC check.
254  
255 67 return;
256 }
257  
258 33 1;
259  
260 __END__
« Object/Series.pm ↑ Summary Object/PublicationDate.pm »