File Coverage

blib/lib/XML/Amazon/Item.pm
Criterion Covered Total %
statement 15 76 19.7
branch 0 6 0.0
condition n/a
subroutine 5 19 26.3
pod 14 14 100.0
total 34 115 29.5


line stmt bran cond sub pod time code
1             package XML::Amazon::Item;
2              
3 1     1   4 use strict;
  1         2  
  1         25  
4 1     1   2 use warnings;
  1         2  
  1         21  
5              
6 1     1   3 use LWP::Simple;
  1         3  
  1         12  
7 1     1   268 use XML::Simple;
  1         1  
  1         6  
8 1     1   47 use utf8;
  1         2  
  1         4  
9              
10             sub new {
11 0     0 1   my($pkg, %options) = @_;
12              
13             bless {
14             title => $options{'title'},
15             authors => $options{'authors'},
16             artists => $options{'artists'},
17             creators => $options{'creators'},
18             directors => $options{'directors'},
19             actors => $options{'actors'},
20             type => $options{'type'},
21             url => $options{'url'},
22             smallimage => $options{'smallimage'},
23             mediumimage => $options{'mediumimage'},
24             largeimage => $options{'largeimage'},
25             publisher => $options{'publisher'},
26 0           price => $options{'price'},
27             }, $pkg;
28             }
29              
30             sub creators_all {
31 0     0 1   my $self = shift;
32 0           my @list;
33 0           for (my $i; $self->{authors}->[$i]; $i++){
34 0           push @list, $self->{authors}->[$i];
35             }
36 0           for (my $i; $self->{artists}->[$i]; $i++){
37 0           push @list, $self->{artists}->[$i];
38             }
39 0           for (my $i; $self->{creators}->[$i]; $i++){
40 0           push @list, $self->{creators}->[$i];
41             }
42 0           return @list;
43             }
44              
45             sub made_by {
46 0     0 1   my $self = shift;
47 0           my @list;
48 0           for (my $i; $self->{authors}->[$i]; $i++){
49 0           push @list, $self->{authors}->[$i];
50             }
51 0           for (my $i; $self->{artists}->[$i]; $i++){
52 0           push @list, $self->{artists}->[$i];
53             }
54              
55 0           for (my $i; $self->{creators}->[$i]; $i++){
56 0           push @list, $self->{creators}->[$i];
57             }
58              
59 0           for (my $i; $self->{directors}->[$i]; $i++){
60 0           push @list, $self->{directors}->[$i];
61             }
62              
63 0           for (my $i; $self->{actors}->[$i]; $i++){
64 0           push @list, $self->{actors}->[$i];
65             }
66              
67              
68 0           my %tmp;
69 0           @list = grep( !$tmp{$_}++, @list );
70              
71 0           return @list;
72             }
73              
74             sub authors {
75 0     0 1   my $self = shift;
76 0           my @list;
77 0           for (my $i; $self->{authors}->[$i]; $i++){
78 0           push @list, $self->{authors}->[$i];
79             }
80 0           return @list;
81             }
82              
83             sub artists {
84 0     0 1   my $self = shift;
85 0           my @list;
86 0           for (my $i; $self->{artists}->[$i]; $i++){
87 0           push @list, $self->{artists}->[$i];
88             }
89 0           return @list;
90             }
91              
92             sub creators {
93 0     0 1   my $self = shift;
94 0           my @list;
95 0           for (my $i; $self->{creators}->[$i]; $i++){
96 0           push @list, $self->{creators}->[$i];
97             }
98 0           return @list;
99             }
100              
101             sub publisher {
102 0     0 1   my $self = shift;
103 0           return $self->{publisher};
104             }
105              
106             sub asin {
107 0     0 1   my $self = shift;
108 0           return $self->{asin};
109             }
110              
111             sub title {
112 0     0 1   my $self = shift;
113 0           return $self->{title};
114             }
115              
116             sub author {
117 0     0 1   my $self = shift;
118 0           return @{$self->authors}[0];
  0            
119             }
120              
121             sub image {
122 0     0 1   my $self = shift;
123 0           my $size = shift;
124              
125 0 0         return $self->{smallimage} if $size eq 's';
126 0 0         return $self->{mediumimage} if $size eq 'm';
127 0 0         return $self->{largeimage} if $size eq 'l';
128              
129             }
130              
131             sub url {
132 0     0 1   my $self = shift;
133 0           return $self->{url};
134             }
135              
136             sub type {
137 0     0 1   my $self = shift;
138 0           return $self->{type};
139             }
140              
141             sub price {
142 0     0 1   my $self = shift;
143 0           return $self->{price};
144             }
145              
146             1;
147              
148             __END__