File Coverage

blib/lib/EBook/FB2/Description/PublishInfo.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


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::PublishInfo;
26 1     1   1751 use Moose;
  0            
  0            
27              
28             use EBook::FB2::Description::Sequence;
29              
30             has [qw/book_name publisher city year isbn/] => (isa => 'Str', is => 'rw');
31              
32             has _sequences => (
33             isa => 'ArrayRef',
34             is => 'ro',
35             traits => ['Array'],
36             default => sub { [] },
37             handles => {
38             sequences => 'elements',
39             add_sequence => 'push',
40             },
41             );
42              
43             sub load
44             {
45             my ($self, $node) = @_;
46              
47             my @nodes = $node->findnodes('book-name');
48             if (@nodes) {
49             $self->book_name($nodes[0]->string_value());
50             }
51              
52             @nodes = $node->findnodes('publisher');
53             if (@nodes) {
54             $self->publisher($nodes[0]->string_value());
55             }
56              
57             @nodes = $node->findnodes('city');
58             if (@nodes) {
59             $self->city($nodes[0]->string_value());
60             }
61              
62             @nodes = $node->findnodes('year');
63             if (@nodes) {
64             $self->year($nodes[0]->string_value());
65             }
66              
67             @nodes = $node->findnodes('isbn');
68             if (@nodes) {
69             $self->isbn($nodes[0]->string_value());
70             }
71              
72             @nodes = $node->findnodes('sequence');
73             foreach my $node (@nodes) {
74             my $seq = EBook::FB2::Description::Sequence->new();
75             $seq->load($node);
76             $self->add_sequence($seq);
77             }
78             }
79              
80             1;
81              
82             __END__
83             =head1 NAME
84              
85             EBook::FB2::Description::PublishInfo
86              
87             =head1 SYNOPSIS
88              
89             EBook::FB2::Description::PublishInfo - TODO
90              
91             =head1 SUBROUTINES/METHODS
92              
93             =over 4
94              
95             =item book_name()
96              
97             Returns publication name
98              
99             =item city()
100              
101             Returns city of publication
102              
103             =item isbn()
104              
105             Returns publication ISDN
106              
107             =item publisher()
108              
109             Returns publisher
110              
111             =item sequences()
112              
113             Sequences publication belongs to (reference to L<EBook::FB2::Description::Sequence>)
114              
115             =item year()
116              
117             Returns year of publication
118              
119              
120             =back
121              
122             =head1 AUTHOR
123              
124             Oleksandr Tymoshenko, E<lt>gonzo@bluezbox.comE<gt>
125              
126             =head1 BUGS
127              
128             Please report any bugs or feature requests to E<lt>gonzo@bluezbox.comE<gt>
129              
130             =head1 LICENSE AND COPYRIGHT
131              
132             Copyright 2009, 2010 Oleksandr Tymoshenko.
133              
134             L<http://bluezbox.com>
135              
136             This module is free software; you can redistribute it and/or
137             modify it under the terms of the BSD license. See the F<LICENSE> file
138             included with this distribution.