line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1249
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::Moo::Document; |
4
|
1
|
|
|
1
|
|
6
|
use base qw (XML::Writer); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1262
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
$Net::Moo::Document::VERSION = '0.11'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::Moo::Document - object methods to generate XML documents for the Moo API. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
There is no SYNOPSIS. Consult Net::Moo for details. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Object methods to generate XML documents for the Moo API. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
1
|
|
my $pkg = shift; |
24
|
0
|
|
|
|
|
|
my $fh = shift; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my %args = ( |
27
|
|
|
|
|
|
|
'OUTPUT' => $fh, |
28
|
|
|
|
|
|
|
'DATA_MODE' => 1, |
29
|
|
|
|
|
|
|
'DATA_INDENT' => 2, |
30
|
|
|
|
|
|
|
'NAMESPACES' => 1, |
31
|
|
|
|
|
|
|
'ENCODING' => 'utf-8', |
32
|
|
|
|
|
|
|
'PREFIX_MAP' => {"http://www.w3.org/2001/XMLSchema-instance" => 'xsi'} |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $self = $pkg->SUPER::new(%args); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
bless $self, $pkg; |
38
|
0
|
|
|
|
|
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub startDocument { |
42
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
my $args = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$self->xmlDecl("UTF-8"); |
46
|
0
|
|
|
|
|
|
$self->startTag("moo", ["http://www.w3.org/2001/XMLSchema-instance", "noNamespaceSchemaLocation"] => "http://www.moo.com/xsd/api_0.7.xsd"); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->startTag("request"); |
49
|
0
|
|
|
|
|
|
$self->startTag("version"); |
50
|
0
|
|
|
|
|
|
$self->characters("0.7"); |
51
|
0
|
|
|
|
|
|
$self->endTag("version"); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->startTag("api_key"); |
54
|
0
|
|
|
|
|
|
$self->characters($args->{'api_key'}); |
55
|
0
|
|
|
|
|
|
$self->endTag("api_key"); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->startTag("call"); |
58
|
0
|
|
|
|
|
|
$self->characters("build"); |
59
|
0
|
|
|
|
|
|
$self->endTag("call"); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->endTag("request"); |
62
|
0
|
|
|
|
|
|
$self->startTag("payload"); |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub endDocument { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
$self->endTag("payload"); |
70
|
0
|
|
|
|
|
|
$self->endTag("moo"); |
71
|
0
|
|
|
|
|
|
$self->end(); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub product { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $type = shift; |
77
|
0
|
|
|
|
|
|
my $designs = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$self->startTag("product"); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$self->startTag("product_type"); |
82
|
0
|
|
|
|
|
|
$self->characters($type); |
83
|
0
|
|
|
|
|
|
$self->endTag("product_type"); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->startTag("designs"); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
foreach my $data (@$designs){ |
88
|
0
|
|
|
|
|
|
$data->{'__product'} = $type; |
89
|
0
|
|
|
|
|
|
$self->design($data); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$self->endTag("designs"); |
93
|
0
|
|
|
|
|
|
$self->endTag("product"); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub design { |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
my $args = shift; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
$self->startTag("design"); |
101
|
0
|
|
|
|
|
|
$self->image($args); |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
if ($args->{'text'}){ |
104
|
0
|
|
|
|
|
|
$self->text_collection($args); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$self->endTag("design"); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub image { |
111
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
112
|
0
|
|
|
|
|
|
my $args = shift; |
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
my $type = ($args->{'type'}) ? $args->{'type'} : 'variable'; |
115
|
0
|
0
|
|
|
|
|
my $crop = ($args->{'crop'}) ? $args->{'type'} : 'auto'; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$self->startTag("image"); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$self->startTag("url"); |
120
|
0
|
|
|
|
|
|
$self->characters($args->{'url'}); |
121
|
0
|
|
|
|
|
|
$self->endTag("url"); |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$self->startTag("type"); |
124
|
0
|
|
|
|
|
|
$self->characters($type); |
125
|
0
|
|
|
|
|
|
$self->endTag("type"); |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$self->startTag("crop"); |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
if ($crop eq 'auto'){ |
130
|
0
|
|
|
|
|
|
$self->startTag("auto"); |
131
|
0
|
|
|
|
|
|
$self->characters("true"); |
132
|
0
|
|
|
|
|
|
$self->endTag("auto"); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
else { |
136
|
0
|
|
|
|
|
|
$self->startTag("manual"); |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
foreach my $el (keys %{$args->{'manual'}}){ |
|
0
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->startTag($el); |
140
|
0
|
|
|
|
|
|
$self->characters($crop->{$el}); |
141
|
0
|
|
|
|
|
|
$self->endTag($el); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$self->endTag("manual"); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$self->endTag("crop"); |
148
|
0
|
|
|
|
|
|
$self->endTag("image"); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub text_collection { |
152
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
153
|
0
|
|
|
|
|
|
my $data = shift; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
my $type = $data->{'__product'}; |
156
|
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
|
if ($type eq 'greetingcard'){ |
158
|
0
|
|
|
|
|
|
return $self->text_collection_greetingcard($data); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# because the order of elements apparently matters... |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
my @possible = ('id', 'string', 'bold', 'align', 'font', 'colour'); |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$self->startTag("text_collection"); |
166
|
0
|
|
|
|
|
|
$self->startTag($type); |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
foreach my $ln (@{$data->{'text'}}){ |
|
0
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
$self->startTag('text_line'); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
foreach my $el (@possible){ |
173
|
0
|
0
|
|
|
|
|
if (exists($ln->{$el})){ |
174
|
0
|
|
|
|
|
|
$self->startTag($el); |
175
|
0
|
|
|
|
|
|
$self->characters($ln->{$el}); |
176
|
0
|
|
|
|
|
|
$self->endTag($el); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
$self->endTag('text_line'); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
$self->endTag($type); |
184
|
0
|
|
|
|
|
|
$self->endTag("text_collection"); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub text_collection_greetingcard { |
188
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
189
|
0
|
|
|
|
|
|
my $data = shift; |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
$self->startTag("text_collection"); |
192
|
0
|
|
|
|
|
|
$self->startTag('greetingcard'); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# because the order of elements apparently matters... |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my %possible = ('main' => ['string', 'align', 'font', 'colour'], |
197
|
|
|
|
|
|
|
'back' => ['id', 'string', 'bold', 'align', 'font', 'colour']); |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
foreach my $part ('main', 'back'){ |
200
|
|
|
|
|
|
|
|
201
|
0
|
0
|
|
|
|
|
if (! exists($data->{'text'}->{$part})){ |
202
|
0
|
|
|
|
|
|
next; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
$self->startTag($part); |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
foreach my $ln (@{$data->{'text'}->{$part}}){ |
|
0
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|
209
|
0
|
0
|
|
|
|
|
if ($part eq 'back'){ |
210
|
0
|
|
|
|
|
|
$self->startTag('text_line'); |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
foreach my $el (@{$possible{$part}}){ |
|
0
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
0
|
0
|
|
|
|
|
if (exists($ln->{$el})){ |
216
|
0
|
|
|
|
|
|
$self->startTag($el); |
217
|
0
|
|
|
|
|
|
$self->characters($ln->{$el}); |
218
|
0
|
|
|
|
|
|
$self->endTag($el); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
|
if ($part eq 'back'){ |
223
|
0
|
|
|
|
|
|
$self->endTag('text_line'); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
$self->endTag($part); |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
$self->endTag('greetingcard'); |
231
|
0
|
|
|
|
|
|
$self->endTag("text_collection"); |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 VERSION |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
0.11 |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 DATE |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
$Date: 2008/06/19 15:15:34 $ |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 AUTHOR |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Aaron Straup Cope Eascope@cpan.orgE |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 SEE ALSO |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
L |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 LICENSE |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Copyright (c) 2008 Aaron Straup Cope. All rights reserved. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This is free software. You may redistribute it and/or |
255
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
return 1; |