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
|
|
|
|
|
|
|
package EBook::EPUB::Spine; |
25
|
1
|
|
|
1
|
|
4601
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use EBook::EPUB::Spine::Itemref; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has toc => ( isa => 'Str', is => 'rw' ); |
29
|
|
|
|
|
|
|
has itemrefs => ( |
30
|
|
|
|
|
|
|
traits => ['Array'], |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
33
|
|
|
|
|
|
|
default => sub { [] }, |
34
|
|
|
|
|
|
|
handles => { |
35
|
|
|
|
|
|
|
all_itemrefs => 'elements', |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub encode |
40
|
|
|
|
|
|
|
{ |
41
|
|
|
|
|
|
|
my ($self, $writer) = @_; |
42
|
|
|
|
|
|
|
$writer->startTag("spine", |
43
|
|
|
|
|
|
|
toc => $self->toc, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
foreach my $itemref (@{$self->itemrefs()}) { |
47
|
|
|
|
|
|
|
$itemref->encode($writer); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$writer->endTag("spine"); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add_itemref |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
my ($self, @args) = @_; |
56
|
|
|
|
|
|
|
my $itemref = EBook::EPUB::Spine::Itemref->new(@args); |
57
|
|
|
|
|
|
|
push @{$self->itemrefs()}, $itemref; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
no Moose; |
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
EBook::EPUB::Spine |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Class that represents B<spine> element of OPF document |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The B<spine> element organizes the associated OPS Content Documents into the linear reading order of the publication. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item add_itemref(%opts) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Add reference an OPS Content Document designated in the B<manifest>. %opts is an anonymous hash, for possible key |
87
|
|
|
|
|
|
|
values see L<EBook::EPUB::Spine::Itemref> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item all_references() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns array of EBook::EPUB::Spine::Itemref objects, current content of B<spine> element |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item encode($xmlwriter) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Encode object to XML form using XML::Writer instance |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item new() |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Create new object |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 BUGS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright 2009, 2010 Oleksandr Tymoshenko. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L<http://bluezbox.com> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
120
|
|
|
|
|
|
|
modify it under the terms of the BSD license. See the F<LICENSE> file |
121
|
|
|
|
|
|
|
included with this distribution. |