Wikidata/Item/BookEdition.pm

filter: Statementstmt 82.0% 55 / 67 Branchbran 55.8% 19 / 34 Conditioncond 58.3% 14 / 24 MC/DCmcdc 42.8% 6 / 14 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 1 totaltotal 68.8% 104 / 151 CC 26 SCAR 35.1
CC
26
Cov
70%
_description
47.4
wikidata
6.0
BEGIN
1.0
CRAP 33.5
« Wikidata/Item.pm ↑ Summary Wikidata.pm »
1 package MARC::Convert::Wikidata::Item::BookEdition;
2  
3 10 ▶use base qw(MARC::Convert::Wikidata::Item);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Unicode::UTF8 qw(decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Wikibase::Datatype::Item;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Wikibase::Datatype::Snak;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Wikibase::Datatype::Statement;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Wikibase::Datatype::Value::Item;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 10 our $VERSION = 0.34;
15  
16 0 ▶sub wikidata {
Subroutine wikidata: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my $self = shift;
18  
19 0 my $instance_value = 'Q3331189';
20 0 ▶ if ($self->wikidata_translators) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->wikidata_translators) 0 0 0
21 0 $instance_value = 'Q21112633';
22 }
23  
24 0 my $wikidata = Wikibase::Datatype::Item->new(
25 $self->wikidata_labels,
26 $self->wikidata_descriptions,
27 'statements' => [
28 # instance of: version, edition, or translation
29 Wikibase::Datatype::Statement->new(
30 'snak' => Wikibase::Datatype::Snak->new(
31 'datatype' => 'wikibase-item',
32 'datavalue' => Wikibase::Datatype::Value::Item->new(
33 'value' => $instance_value,
34 ),
35 'property' => 'P31',
36 ),
37 ),
38  
39 $self->wikidata_authors,
40 $self->wikidata_authors_of_afterword,
41 $self->wikidata_authors_of_introduction,
42 $self->wikidata_compilers,
43 $self->wikidata_dml,
44 $self->wikidata_edition_number,
45 $self->wikidata_editors,
46 $self->wikidata_end_time,
47 $self->wikidata_external_ids,
48 $self->wikidata_illustrators,
49 $self->wikidata_isbn_10,
50 $self->wikidata_isbn_13,
51 $self->wikidata_krameriuses,
52 $self->wikidata_language,
53 $self->wikidata_number_of_pages,
54 $self->wikidata_place_of_publication,
55 $self->wikidata_photographers,
56 $self->wikidata_publication_date,
57 $self->wikidata_publishers,
58 $self->wikidata_series,
59 $self->wikidata_start_time,
60 $self->wikidata_subtitles,
61 $self->wikidata_title,
62 $self->wikidata_translators,
63 ],
64 );
65  
66 0 return $wikidata;
67 }
68  
69 6 ▶sub _description {
Subroutine _description: called CC=25 SCAR=38.6
70 6 my ($self, $lang) = @_;
71  
72 6 my $ret;
73 6 my @lang = @{$self->{'transform_object'}->languages};
74 6 ▶ if ($lang eq 'cs') {
Branch: 2 branches
BranchTrueFalseTotal
if ($lang eq 'cs') { } 3 3 6
elsif ($lang eq 'en') { } 3 0 3
75 3 ▶ if (@lang == 1 && $lang[0] eq 'cze') {
Branch: 3 branches
BranchTrueFalseTotal
if (@lang == 1 and $lang[0] eq 'cze') { } 1 2 3
elsif (@lang == 1 and $lang[0] eq 'slo') { } 1 1 2
elsif (@lang > 1) { } 1 0 1
Condition100%3/3
@lang == 1 and $lang[0] eq "cze"
!ll&&!rl&&r
111
MC/DC100%2/2
@lang == 1 and $lang[0] eq "cze"
@lang == 1 $lang[0] eq "cze"
Truth table100%3/3
A and B
A= @lang == 1B= $lang[0] eq "cze"
ABresult
0X0
100
111
76 1 $ret = decode_utf8('české');
77 ▶ } elsif (@lang == 1 && $lang[0] eq 'slo') {
Condition66%2/3
@lang == 1 and $lang[0] eq "slo"
!ll&&!rl&&r
101
MC/DC50%1/2
@lang == 1 and $lang[0] eq "slo"
@lang == 1 $lang[0] eq "slo"
Truth table66%2/3
A and B
A= @lang == 1B= $lang[0] eq "slo"
ABresult
0X0
100
111
78 1 $ret = decode_utf8('slovenské');
79 } elsif (@lang > 1) {
80 1 ▶ if (@lang == 2 && $lang[0] eq 'cze' && $lang[1] eq 'slo') {
Branch: 1 branch
BranchTrueFalseTotal
if (@lang == 2 and $lang[0] eq 'cze' and $lang[1] eq 'slo') { } 1 0 1
Condition33%2/6
@lang == 2 and $lang[0] eq "cze" and $lang[1] eq "slo"
!ll&&!rl&&r
001
@lang == 2 and $lang[0] eq "cze"
!ll&&!rl&&r
001
MC/DC0%0/3
@lang == 2 and $lang[0] eq "cze" and $lang[1] eq "slo"
@lang == 2 $lang[0] eq "cze" $lang[1] eq "slo"
Truth table25%1/4
A and B and C
A= @lang == 2B= $lang[0] eq "cze"C= $lang[1] eq "slo"
ABCresult
0XX0
10X0
1100
1111
81 1 $ret = decode_utf8('česko-slovenské');
82 } else {
83 0 err "Multiple language description isn't supported.";
84 }
85 } else {
86 0 err "Description for language '$lang[0]' isn't supported.";
87 }
88 3 ▶ if (length($ret) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $ret > 0) 3 0 3
89 3 $ret .= ' ';
90 }
91 3 $ret .= decode_utf8('knižní vydání');
92 3 ▶ if (defined $self->{'transform_object'}->publication_date) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'transform_object'}->publication_date) { } 3 0 3
elsif (defined $self->{'transform_object'}->start_time) { } 0 0 0
93 3 $ret .= ' z roku '.$self->{'transform_object'}->publication_date;
94 } elsif (defined $self->{'transform_object'}->start_time) {
95 $ret .= ' z let '.$self->{'transform_object'}->start_time.'-'.
96 0 $self->{'transform_object'}->end_time;
97 }
98  
99 } elsif ($lang eq 'en') {
100 3 ▶ if (defined $self->{'transform_object'}->publication_date) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'transform_object'}->publication_date) { } 3 0 3
elsif (defined $self->{'transform_object'}->start_time) { } 0 0 0
101 3 $ret = $self->{'transform_object'}->publication_date.' ';
102 } elsif (defined $self->{'transform_object'}->start_time) {
103 $ret = $self->{'transform_object'}->start_time.'-'.
104 0 $self->{'transform_object'}->end_time.' ';
105 }
106 3 ▶ if (@lang == 1 && $lang[0] eq 'cze') {
Branch: 3 branches
BranchTrueFalseTotal
if (@lang == 1 and $lang[0] eq 'cze') { } 1 2 3
elsif (@lang == 1 and $lang[0] eq 'slo') { } 1 1 2
elsif (@lang > 1) { } 1 0 1
Condition100%3/3
@lang == 1 and $lang[0] eq "cze"
!ll&&!rl&&r
111
MC/DC100%2/2
@lang == 1 and $lang[0] eq "cze"
@lang == 1 $lang[0] eq "cze"
Truth table100%3/3
A and B
A= @lang == 1B= $lang[0] eq "cze"
ABresult
0X0
100
111
107 1 $ret .= 'Czech';
108 ▶ } elsif (@lang == 1 && $lang[0] eq 'slo') {
Condition66%2/3
@lang == 1 and $lang[0] eq "slo"
!ll&&!rl&&r
101
MC/DC50%1/2
@lang == 1 and $lang[0] eq "slo"
@lang == 1 $lang[0] eq "slo"
Truth table66%2/3
A and B
A= @lang == 1B= $lang[0] eq "slo"
ABresult
0X0
100
111
109 1 $ret .= 'Slovak';
110 } elsif (@lang > 1) {
111 1 ▶ if (@lang == 2 && $lang[0] eq 'cze' && $lang[1] eq 'slo') {
Branch: 1 branch
BranchTrueFalseTotal
if (@lang == 2 and $lang[0] eq 'cze' and $lang[1] eq 'slo') { } 1 0 1
Condition33%2/6
@lang == 2 and $lang[0] eq "cze" and $lang[1] eq "slo"
!ll&&!rl&&r
001
@lang == 2 and $lang[0] eq "cze"
!ll&&!rl&&r
001
MC/DC0%0/3
@lang == 2 and $lang[0] eq "cze" and $lang[1] eq "slo"
@lang == 2 $lang[0] eq "cze" $lang[1] eq "slo"
Truth table25%1/4
A and B and C
A= @lang == 2B= $lang[0] eq "cze"C= $lang[1] eq "slo"
ABCresult
0XX0
10X0
1100
1111
112 1 $ret .= 'Czech-Slovak';
113 } else {
114 0 err "Multiple language description isn't supported.";
115 }
116 } else {
117 0 err "Description for language '$lang[0]' isn't supported.";
118 }
119 3 ▶ if (length($ret) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $ret > 0) 3 0 3
120 3 $ret .= ' ';
121 }
122 3 $ret .= 'book edition';
123 }
124  
125 6 return $ret;
126 }
127  
128 10 1;
129  
130 __END__
« Wikidata/Item.pm ↑ Summary Wikidata.pm »