| 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::DocumentInfo; | ||||||||||
| 26 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | use EBook::FB2::Description::Author; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | 1 | has [qw/program_used date src_ocr id version history/] => (isa => 'Str', is => 'rw'); | |||||||||
| 31 | |||||||||||
| 32 | has _authors => ( | ||||||||||
| 33 | isa => 'ArrayRef', | ||||||||||
| 34 | is => 'ro', | ||||||||||
| 35 | traits => ['Array'], | ||||||||||
| 36 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 1 | handles => { | |||||||||
| 38 | authors => 'elements', | ||||||||||
| 39 | add_author => 'push', | ||||||||||
| 40 | }, | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | has _src_urls => ( | ||||||||||
| 44 | isa => 'ArrayRef', | ||||||||||
| 45 | is => 'ro', | ||||||||||
| 46 | traits => ['Array'], | ||||||||||
| 47 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 48 | 1 | handles => { | |||||||||
| 49 | src_urls => 'elements', | ||||||||||
| 50 | add_src_url => 'push', | ||||||||||
| 51 | }, | ||||||||||
| 52 | ); | ||||||||||
| 53 | |||||||||||
| 54 | has _publishers => ( | ||||||||||
| 55 | isa => 'ArrayRef', | ||||||||||
| 56 | is => 'ro', | ||||||||||
| 57 | traits => ['Array'], | ||||||||||
| 58 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 59 | 1 | handles => { | |||||||||
| 60 | publishers => 'elements', | ||||||||||
| 61 | add_publisher => 'push', | ||||||||||
| 62 | }, | ||||||||||
| 63 | ); | ||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | sub load | ||||||||||
| 67 | 0 | ▶ | { | ||||||||
|
Subroutine
load: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||
| 68 | 0 | my ($self, $node) = @_; | |||||||||
| 69 | |||||||||||
| 70 | 0 | my @nodes = $node->findnodes('author'); | |||||||||
| 71 | 0 | foreach my $author_node (@nodes) { | |||||||||
| 72 | 0 | my $author = EBook::FB2::Description::Author->new; | |||||||||
| 73 | 0 | $author->load($author_node); | |||||||||
| 74 | 0 | $self->add_author($author); | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | @nodes = $node->findnodes('program-used'); | |||||||||
| 78 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | $self->program_used($nodes[0]->string_value()); | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | 0 | @nodes = $node->findnodes('date'); | |||||||||
| 83 | 0 | ▶ | if (@nodes == 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 0 | warn "Wrong number of <date> elements in <document-info>"; | |||||||||
| 85 | } | ||||||||||
| 86 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 0 | $self->date($nodes[0]->string_value()); | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 0 | @nodes = $node->findnodes('id'); | |||||||||
| 91 | 0 | ▶ | if (@nodes == 0) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | warn "Wrong number of <id> elements in <document-info>"; | |||||||||
| 93 | } | ||||||||||
| 94 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 0 | $self->id($nodes[0]->string_value()); | |||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | 0 | @nodes = $node->findnodes('src-url'); | |||||||||
| 99 | 0 | foreach my $src_url_node (@nodes) { | |||||||||
| 100 | 0 | $self->add_src_url($src_url_node->string_value()); | |||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 0 | @nodes = $node->findnodes('src-ocr'); | |||||||||
| 104 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 0 | $self->src_ocr($nodes[0]->string_value()); | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 0 | @nodes = $node->findnodes('history'); | |||||||||
| 109 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 110 | 0 | $self->history($nodes[0]->string_value()); | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | 0 | @nodes = $node->findnodes('version'); | |||||||||
| 114 | 0 | ▶ | if (@nodes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | 0 | $self->version($nodes[0]->string_value()); | |||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | |||||||||||
| 119 | |||||||||||
| 120 | 0 | @nodes = $node->findnodes('publisher'); | |||||||||
| 121 | 0 | foreach my $publisher_node (@nodes) { | |||||||||
| 122 | 0 | $self->add_publisher($publisher_node->string_value()); | |||||||||
| 123 | } | ||||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 1 | 1; | |||||||||
| 127 | |||||||||||
| 128 | __END__ | ||||||||||