| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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::TitleInfo; |
|
26
|
1
|
|
|
1
|
|
1808
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use EBook::FB2::Description::Author; |
|
28
|
|
|
|
|
|
|
use EBook::FB2::Description::Genre; |
|
29
|
|
|
|
|
|
|
use EBook::FB2::Description::Sequence; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has [qw/book_title keywords date lang src_lang/] => ( |
|
32
|
|
|
|
|
|
|
isa => 'Str', |
|
33
|
|
|
|
|
|
|
is => 'rw' |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has annotation => ( isa => 'Ref', is => 'rw' ); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has _genres => ( |
|
39
|
|
|
|
|
|
|
traits => ['Array'], |
|
40
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
|
41
|
|
|
|
|
|
|
is => 'rw', |
|
42
|
|
|
|
|
|
|
default => sub { [] }, |
|
43
|
|
|
|
|
|
|
handles => { |
|
44
|
|
|
|
|
|
|
genres => 'elements', |
|
45
|
|
|
|
|
|
|
add_genre => 'push', |
|
46
|
|
|
|
|
|
|
}, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has _authors => ( |
|
50
|
|
|
|
|
|
|
traits => ['Array'], |
|
51
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
|
52
|
|
|
|
|
|
|
is => 'rw', |
|
53
|
|
|
|
|
|
|
default => sub { [] }, |
|
54
|
|
|
|
|
|
|
handles => { |
|
55
|
|
|
|
|
|
|
authors => 'elements', |
|
56
|
|
|
|
|
|
|
add_author => 'push', |
|
57
|
|
|
|
|
|
|
}, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has _translators => ( |
|
61
|
|
|
|
|
|
|
traits => ['Array'], |
|
62
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
|
63
|
|
|
|
|
|
|
is => 'rw', |
|
64
|
|
|
|
|
|
|
default => sub { [] }, |
|
65
|
|
|
|
|
|
|
handles => { |
|
66
|
|
|
|
|
|
|
translators => 'elements', |
|
67
|
|
|
|
|
|
|
add_translator => 'push', |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has _sequences => ( |
|
72
|
|
|
|
|
|
|
traits => ['Array'], |
|
73
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
|
74
|
|
|
|
|
|
|
is => 'rw', |
|
75
|
|
|
|
|
|
|
default => sub { [] }, |
|
76
|
|
|
|
|
|
|
handles => { |
|
77
|
|
|
|
|
|
|
sequences => 'elements', |
|
78
|
|
|
|
|
|
|
add_sequence => 'push', |
|
79
|
|
|
|
|
|
|
}, |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has _coverpages => ( |
|
83
|
|
|
|
|
|
|
traits => ['Array'], |
|
84
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
85
|
|
|
|
|
|
|
is => 'rw', |
|
86
|
|
|
|
|
|
|
default => sub { [] }, |
|
87
|
|
|
|
|
|
|
handles => { |
|
88
|
|
|
|
|
|
|
coverpages => 'elements', |
|
89
|
|
|
|
|
|
|
add_coverpage => 'push', |
|
90
|
|
|
|
|
|
|
}, |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub load |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
|
|
|
|
|
|
my ($self, $node) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my @nodes = $node->findnodes('book-title'); |
|
98
|
|
|
|
|
|
|
if (@nodes) { |
|
99
|
|
|
|
|
|
|
$self->book_title($nodes[0]->string_value); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
@nodes = $node->findnodes('keywords'); |
|
103
|
|
|
|
|
|
|
if (@nodes) { |
|
104
|
|
|
|
|
|
|
$self->keywords($nodes[0]->string_value); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
@nodes = $node->findnodes('lang'); |
|
108
|
|
|
|
|
|
|
if (@nodes) { |
|
109
|
|
|
|
|
|
|
$self->lang($nodes[0]->string_value); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
@nodes = $node->findnodes('src-lang'); |
|
113
|
|
|
|
|
|
|
if (@nodes) { |
|
114
|
|
|
|
|
|
|
$self->src_lang($nodes[0]->string_value); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
@nodes = $node->findnodes('date'); |
|
118
|
|
|
|
|
|
|
if (@nodes) { |
|
119
|
|
|
|
|
|
|
# TODO: parse node to ::Data object |
|
120
|
|
|
|
|
|
|
$self->date($nodes[0]->string_value); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Now handle multiple entities |
|
124
|
|
|
|
|
|
|
@nodes = $node->findnodes('author'); |
|
125
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
126
|
|
|
|
|
|
|
my $author = EBook::FB2::Description::Author->new; |
|
127
|
|
|
|
|
|
|
$author->load($node); |
|
128
|
|
|
|
|
|
|
$self->add_author($author); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
@nodes = $node->findnodes('translator'); |
|
132
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
133
|
|
|
|
|
|
|
my $translator = EBook::FB2::Description::Author->new; |
|
134
|
|
|
|
|
|
|
$translator->load($node); |
|
135
|
|
|
|
|
|
|
$self->add_translator($translator); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
@nodes = $node->findnodes('genre'); |
|
139
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
140
|
|
|
|
|
|
|
my $genre = EBook::FB2::Description::Genre->new; |
|
141
|
|
|
|
|
|
|
$genre->load($node); |
|
142
|
|
|
|
|
|
|
$self->add_genre($genre); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
@nodes = $node->findnodes('sequence'); |
|
146
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
147
|
|
|
|
|
|
|
my $seq = EBook::FB2::Description::Sequence->new; |
|
148
|
|
|
|
|
|
|
$seq->load($node); |
|
149
|
|
|
|
|
|
|
$self->add_sequence($seq); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
@nodes = $node->findnodes('coverpage/image'); |
|
153
|
|
|
|
|
|
|
foreach my $node (@nodes) { |
|
154
|
|
|
|
|
|
|
my $map = $node->getAttributes; |
|
155
|
|
|
|
|
|
|
# find href attribute, a litle bit hackerish |
|
156
|
|
|
|
|
|
|
my $i = 0; |
|
157
|
|
|
|
|
|
|
while ($i < $map->getLength) { |
|
158
|
|
|
|
|
|
|
my $item = $map->item($i); |
|
159
|
|
|
|
|
|
|
if ($item->getName =~ /:href/i) { |
|
160
|
|
|
|
|
|
|
my $id = $item->getValue; |
|
161
|
|
|
|
|
|
|
$id =~ s/^#//; |
|
162
|
|
|
|
|
|
|
$self->add_coverpage($id); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
$i++; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
@nodes = $node->findnodes('annotation'); |
|
169
|
|
|
|
|
|
|
if (@nodes) { |
|
170
|
|
|
|
|
|
|
$self->annotation($nodes[0]); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |
|
179
|
|
|
|
|
|
|
=head1 NAME |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
EBook::FB2::Description::TitleInfo |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
EBook::FB2::Description::TitleInfo - meta information of hardcopy document |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=over 4 |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item annotation() |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns reference to XML::DOM::Node, parsed annotation |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item authors() |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns list of book authors (references to L<EBook::FB2::Description::Author>) |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item book_title() |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Returns book title |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item coverpages() |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns list of ids that references to images with original cover artwork |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item date() |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Returns book creation date |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item genres() |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Returns list of genres book falls in (references to |
|
214
|
|
|
|
|
|
|
L<EBook::FB2::Description::Genre>) |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item keywords() |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Returns book keyword |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item lang() |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Returns book language: "en", "ru", etc... |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item sequences() |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Returns list of sequences book belongs to (references to L<EBook::FB2::Description::Sequence>) |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item src_lang() |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Original book language. Valid if book is translation. |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item translators() |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Returns list of translators represented by references to |
|
235
|
|
|
|
|
|
|
L<EBook::FB2::Description::Author> objects; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 AUTHOR |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt> |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 BUGS |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt> |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Copyright 2009, 2010 Oleksandr Tymoshenko. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L<http://bluezbox.com> |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
254
|
|
|
|
|
|
|
modify it under the terms of the BSD license. See the F<LICENSE> file |
|
255
|
|
|
|
|
|
|
included with this distribution. |