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::Guide; |
25
|
1
|
|
|
1
|
|
2379
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use EBook::EPUB::Guide::Reference; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has references => ( |
29
|
|
|
|
|
|
|
traits => ['Array'], |
30
|
|
|
|
|
|
|
is => 'ro', |
31
|
|
|
|
|
|
|
isa => 'ArrayRef[Object]', |
32
|
|
|
|
|
|
|
default => sub { [] }, |
33
|
|
|
|
|
|
|
handles => { |
34
|
|
|
|
|
|
|
all_references => 'elements', |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub encode |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my ($self, $writer) = @_; |
41
|
|
|
|
|
|
|
# Only if there are any items |
42
|
|
|
|
|
|
|
if ($self->all_references) { |
43
|
|
|
|
|
|
|
$writer->startTag("guide"); |
44
|
|
|
|
|
|
|
foreach my $ref ($self->all_references()) { |
45
|
|
|
|
|
|
|
$ref->encode($writer); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
$writer->endTag("guide"); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub add_reference |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
my ($self, @args) = @_; |
54
|
|
|
|
|
|
|
my $ref = EBook::EPUB::Guide::Reference->new(@args); |
55
|
|
|
|
|
|
|
push @{$self->references()}, $ref; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
no Moose; |
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
=head1 NAME |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
EBook::EPUB::Guide |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Class that represents B<guide> element of OPF document |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The B<guide> element identifies fundamental structural components of the |
75
|
|
|
|
|
|
|
publication, to enable Reading Systems to provide convenient access to them. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The structural components of the books are listed in B<reference> elements |
78
|
|
|
|
|
|
|
contained within the B<guide> element. These components could refer to the |
79
|
|
|
|
|
|
|
table of contents, list of illustrations, foreword, bibliography, and many |
80
|
|
|
|
|
|
|
other standard parts of the book. Reading Systems are not required to use the |
81
|
|
|
|
|
|
|
B<guide> element in any way. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See section 2.6 of OPF specification |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over 4 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item add_reference(%opts) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Add reference to guide element. %opts is an anonymous hash, for possible key |
92
|
|
|
|
|
|
|
values see L<EBook::EPUB::Guide::Reference> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item all_references() |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns array of EBook::EPUB::Guide::Reference objects, current content of B<guide> element |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item encode($xmlwriter) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Encode object to XML form using XML::Writer instance |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item new() |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Create new object |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 BUGS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Copyright 2009, 2010 Oleksandr Tymoshenko. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<http://bluezbox.com> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
123
|
|
|
|
|
|
|
modify it under the terms of the BSD license. See the F<LICENSE> file |
124
|
|
|
|
|
|
|
included with this distribution. |
125
|
|
|
|
|
|
|
|