| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################### |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This file copyright (c) 2008-2009 by Randy J. Ray, all rights reserved |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Copying and distribution are permitted under the terms of the Artistic |
|
6
|
|
|
|
|
|
|
# License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php) or |
|
7
|
|
|
|
|
|
|
# the GNU LGPL (http://www.opensource.org/licenses/lgpl-license.php). |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
############################################################################### |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Description: Helper file for auto-generating Catalyst::Model::ISBNDB |
|
12
|
|
|
|
|
|
|
# sub-classes by means of a Catalyst project's create.pl |
|
13
|
|
|
|
|
|
|
# script. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# Functions: mk_compclass |
|
16
|
|
|
|
|
|
|
# mk_comptest |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# Global Consts: $VERSION |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
############################################################################### |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Catalyst::Helper::Model::ISBNDB; |
|
23
|
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
7927
|
use 5.008; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
83
|
|
|
25
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
67
|
|
|
26
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
66
|
|
|
27
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
97
|
|
|
28
|
2
|
|
|
2
|
|
1991
|
use subs qw(mk_compclass mk_comptest); |
|
|
2
|
|
|
|
|
39
|
|
|
|
2
|
|
|
|
|
10
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
200
|
use Catalyst::Model::ISBNDB; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$VERSION = '0.12'; |
|
33
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Catalyst::Helper::Model::ISBNDB - Catalyst::Helper assist for ISBNDB |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
perl script/myapp_create.pl model MyISBNDB ISBNDB API_KEY |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This is a B<Catalyst::Helper> component to allow you to add model components |
|
46
|
|
|
|
|
|
|
deriving from the B<Catalyst::Model::ISBNDB> class, using the |
|
47
|
|
|
|
|
|
|
Catalyst-generated C<create.pl> helper-script. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
When run via the creation-helper, a new model class and a simple test suite |
|
50
|
|
|
|
|
|
|
for it will be added to your Catalyst application. The class will be added in |
|
51
|
|
|
|
|
|
|
the same directory as your other models, and the test added to the C<t/> |
|
52
|
|
|
|
|
|
|
directory in the top-level of the project. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 USAGE |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
When the helper script is invoked, you provide it with 3 or 4 arguments: |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over 4 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item C<model> |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is always C<model>, when adding a model component. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item C<MyClass> |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The name of the new class you want to add. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item C<ISBNDB> |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The name of the model class you are deriving from, B<ISBNDB> in this case. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C<API_KEY> |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
(This parameter is optional.) |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The B<isbndb.com> API key your application will be using, if you wish to have |
|
77
|
|
|
|
|
|
|
it explicitly defined in the configuration block of the new class. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
You can provide just C<model> and C<ISBNDB> alone (two arguments), in which |
|
82
|
|
|
|
|
|
|
case the new class will be given a name using your project's class hierarchy |
|
83
|
|
|
|
|
|
|
and ending in C<ISBNDB>, and no default API key will be configured. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This class defines the following two methods: |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item mk_compclass($SELF, $HELPER, [$KEY]) |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Creates the class by using the B<Catalyst::Helper> instance pointed to by |
|
94
|
|
|
|
|
|
|
C<$HELPER>. If C<$KEY> is passed and is non-null, the call to C<config> in |
|
95
|
|
|
|
|
|
|
the generated class will set the value as the default API key used for data |
|
96
|
|
|
|
|
|
|
calls to B<isbndb.com>. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
############################################################################### |
|
101
|
|
|
|
|
|
|
# |
|
102
|
|
|
|
|
|
|
# Sub Name: mk_compclass |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
# Description: Create the component class from one of the two templates |
|
105
|
|
|
|
|
|
|
# provided later, after the __DATA__ token. |
|
106
|
|
|
|
|
|
|
# |
|
107
|
|
|
|
|
|
|
# Arguments: NAME IN/OUT TYPE DESCRIPTION |
|
108
|
|
|
|
|
|
|
# $self in ref Object of this class |
|
109
|
|
|
|
|
|
|
# $helper in ref Catalyst::Helper instance |
|
110
|
|
|
|
|
|
|
# $api_key in scalar Default API key to use |
|
111
|
|
|
|
|
|
|
# |
|
112
|
|
|
|
|
|
|
# Returns: 1 |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
############################################################################### |
|
115
|
|
|
|
|
|
|
sub mk_compclass |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
|
|
|
|
|
|
my ($self, $helper, $api_key) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$helper->{api_key} = $api_key || ''; |
|
120
|
|
|
|
|
|
|
$helper->{this_module} = __PACKAGE__ . "/$VERSION"; |
|
121
|
|
|
|
|
|
|
$helper->{base_module} = |
|
122
|
|
|
|
|
|
|
"Catalyst::Model::ISBNDB/$Catalyst::Model::ISBNDB::VERSION"; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$helper->render_file('modelclass', $helper->{file}); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item mk_comptest($SELF, $HELPER) |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Creates the unit test suite for the new model. Does this by using the |
|
132
|
|
|
|
|
|
|
C<Catalyst::Helper> instance pointed to by C<$HELPER>. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
############################################################################### |
|
137
|
|
|
|
|
|
|
# |
|
138
|
|
|
|
|
|
|
# Sub Name: mk_comptest |
|
139
|
|
|
|
|
|
|
# |
|
140
|
|
|
|
|
|
|
# Description: Create the a basic test-suite for the component class, |
|
141
|
|
|
|
|
|
|
# using the other of the two templates provided after the |
|
142
|
|
|
|
|
|
|
# __DATA__ token. |
|
143
|
|
|
|
|
|
|
# |
|
144
|
|
|
|
|
|
|
# Arguments: NAME IN/OUT TYPE DESCRIPTION |
|
145
|
|
|
|
|
|
|
# $self in ref Object of this class |
|
146
|
|
|
|
|
|
|
# $helper in ref Catalyst::Helper instance |
|
147
|
|
|
|
|
|
|
# |
|
148
|
|
|
|
|
|
|
# Returns: 1 |
|
149
|
|
|
|
|
|
|
# |
|
150
|
|
|
|
|
|
|
############################################################################### |
|
151
|
|
|
|
|
|
|
sub mk_comptest |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
|
|
|
|
|
|
my ($self, $helper) = @_; |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$helper->render_file('modeltest', $helper->{test}); |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=pod |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=back |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L<Catalyst::Model::ISBNDB>, L<Catalyst::Helper> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 BUGS |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-catalyst-model-isbndb at |
|
171
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
|
172
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-ISBNDB>. I will |
|
173
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress on your bug |
|
174
|
|
|
|
|
|
|
as I make changes. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 SUPPORT |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=over 4 |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Model-ISBNDB> |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Catalyst-Model-ISBNDB> |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Catalyst-Model-ISBNDB> |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * Search CPAN |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Catalyst-Model-ISBNDB> |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item * Source code on GitHub |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
L<http://github.com/rjray/catalyst-model-isbndb/tree/master> |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=back |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This file and the code within are copyright (c) 2009 by Randy J. Ray. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Copying and distribution are permitted under the terms of the Artistic |
|
207
|
|
|
|
|
|
|
License 2.0 (L<http://www.opensource.org/licenses/artistic-license-2.0.php>) or |
|
208
|
|
|
|
|
|
|
the GNU LGPL 2.1 (L<http://www.opensource.org/licenses/lgpl-2.1.php>). |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 AUTHOR |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Randy J. Ray C<< <rjray@blackperl.com> >> |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
__DATA__ |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=begin pod_to_ignore |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
__modelclass__ |
|
223
|
|
|
|
|
|
|
# Automatically-generated model component. See [% base_module %]. |
|
224
|
|
|
|
|
|
|
# Generated via helper-class [% this_module %]. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
package [% class %]; |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
use strict; |
|
229
|
|
|
|
|
|
|
use warnings; |
|
230
|
|
|
|
|
|
|
use base 'Catalyst::Model::ISBNDB'; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
[% IF api_key %]__PACKAGE__->config(access_key => '[% api_key %]'); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
[% END %]=head1 NAME |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
[% class %] - Catalyst model derived from Catalyst::Model::ISBNDB |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
See L<[% app %]> |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This is a Catalyst model component that accesses the B<isbndb.com> web |
|
245
|
|
|
|
|
|
|
service. It sub-classes the existing B<Catalyst::Model::ISBNDB> model. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 AUTHOR |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
[% author %] |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
1; |
|
254
|
|
|
|
|
|
|
__modeltest__ |
|
255
|
|
|
|
|
|
|
use strict; |
|
256
|
|
|
|
|
|
|
use warnings; |
|
257
|
|
|
|
|
|
|
use Test::More tests => 2; |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
use_ok('Catalyst::Test', '[% app %]'); |
|
260
|
|
|
|
|
|
|
use_ok('[% class %]'); |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
exit; |