FB2/Description.pm

filter: Statementstmt 36.2% 21 / 58 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 33.3% 26 / 78 CC 8 SCAR 37.3
CC
8
Cov
30%
load
72.0
__ANON__
2.0
BEGIN
1.0
CRAP 41.6
« FB2/Description/Author.pm ↑ Summary FB2/Description/PublishInfo.pm »
1 # Copyright (c) 2009, 2010 Oleksandr Tymoshenko <gonzo@bluezbox.com>
2 # All rights reserved.
3  
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
6 # are met:
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12  
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 # SUCH DAMAGE.
24  
25 package EBook::FB2::Description;
26  
27 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 1 ▶use EBook::FB2::Description::CustomInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use EBook::FB2::Description::DocumentInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use EBook::FB2::Description::PublishInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use EBook::FB2::Description::TitleInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 1 has 'title_info' => (
35 isa => 'Object',
36 is => 'rw',
37 handles => {
38 book_title => 'book_title',
39 authors => 'authors',
40 translators => 'translators',
41 sequences => 'sequences',
42 genres => 'genres',
43 lang => 'lang',
44 src_lang => 'src_lang',
45 date => 'date',
46 keywords => 'keywords',
47 coverpages => 'coverpages',
48 },
49 );
50  
51 1 has 'src_title_info' => (
52 isa => 'Object',
53 is => 'rw',
54 handles => {
55 src_book_title => 'book_title',
56 src_authors => 'authors',
57 src_translators => 'translators',
58 src_sequences => 'sequences',
59 src_genres => 'genres',
60 src_date => 'date',
61 src_keywords => 'keywords',
62 src_coverpages => 'coverpages',
63 },
64 );
65  
66 1 has 'publish_info' => (
67 isa => 'Object',
68 is => 'rw',
69 handles => {
70 publication_title => 'book_name',
71 publisher => 'publisher',
72 publication_city => 'city',
73 publication_year => 'year',
74 isbn => 'isbn',
75 },
76 );
77  
78  
79 1 has 'document_info' => (
80 isa => 'Object',
81 is => 'rw',
82 handles => {
83 document_publishers => 'publishers',
84 document_src_urls => 'src_urls',
85 document_authors => 'authors',
86 document_program_used => 'program_used',
87 document_date => 'date',
88 document_src_ocr => 'src_ocr',
89 document_id => 'id',
90 document_version => 'version',
91 document_history => 'history',
92 },
93 );
94  
95 has '_custom_infos' => (
96 isa => 'ArrayRef[Object]',
97 is => 'ro',
98 traits => ['Array'],
99 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 1 handles => {
101 custom_infos => 'elements',
102 add_custom_info => 'push',
103 },
104 );
105  
106 sub load
107 0 ▶{
Subroutine load: not called CC=8 SCAR=42.8
Pod undocumented
108 0 my ($self, $node) = @_;
109 0 my @title_info_nodes = $node->findnodes('title-info');
110  
111 0 ▶ if (@title_info_nodes != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@title_info_nodes != 1) 0 0 0
112 0 warn ("Wrong number of <title-info> element");
113 0 return;
114 }
115  
116 0 my $title_info = EBook::FB2::Description::TitleInfo->new();
117 0 $title_info->load( $title_info_nodes[0]);
118 0 $self->title_info($title_info);
119  
120 0 my @src_title_info_nodes = $node->findnodes('src-title-info');
121  
122 0 ▶ if (@src_title_info_nodes > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@src_title_info_nodes > 1) 0 0 0
123 0 warn ("Wrong number of <src-title-info> element");
124 0 return;
125 }
126  
127 0 ▶ if (@src_title_info_nodes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@src_title_info_nodes) 0 0 0
128 0 my $src_title_info = EBook::FB2::Description::TitleInfo->new();
129 0 $src_title_info->load( $src_title_info_nodes[0]);
130 0 $self->src_title_info($src_title_info);
131 }
132  
133 0 my @publish_info_nodes = $node->findnodes('publish-info');
134  
135 0 ▶ if (@publish_info_nodes > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@publish_info_nodes > 1) 0 0 0
136 0 warn ("Wrong number of <publish-info> element");
137 0 return;
138 }
139  
140 0 ▶ if (@publish_info_nodes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@publish_info_nodes) 0 0 0
141 0 my $publish_info = EBook::FB2::Description::PublishInfo->new();
142 0 $publish_info->load( $publish_info_nodes[0]);
143 0 $self->publish_info($publish_info);
144 }
145  
146 0 my @document_info_nodes = $node->findnodes('document-info');
147  
148 0 ▶ if (@document_info_nodes != 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@document_info_nodes != 1) 0 0 0
149 0 warn ("Wrong number of <document-info> element");
150 0 return;
151 }
152  
153 0 my $document_info = EBook::FB2::Description::DocumentInfo->new();
154 0 $document_info->load( $document_info_nodes[0]);
155 0 $self->document_info($document_info);
156  
157 0 my @custom_info_nodes = $node->findnodes('custom-info');
158  
159 0 foreach my $n (@custom_info_nodes) {
160 0 my $custom_info = EBook::FB2::Description::CustomInfo->new();
161 0 $custom_info->load( $n );
162 0 $self->add_custom_info($custom_info);
163 }
164  
165 }
166  
167 1 1;
168  
169 __END__
« FB2/Description/Author.pm ↑ Summary FB2/Description/PublishInfo.pm »