| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Helper::Model::CDBI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2346
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
1203
|
use Class::DBI::Loader; |
|
|
1
|
|
|
|
|
251
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Class::DBI; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
15
|
|
|
6
|
1
|
|
|
1
|
|
25
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
630
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Catalyst::Helper::Model::CDBI - Helper for CDBI Models |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
script/create.pl model CDBI CDBI dsn user password |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Helper for CDBI Model. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over 4 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item mk_compclass |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Reads the database and makes a main model class as well as placeholders |
|
27
|
|
|
|
|
|
|
for each table. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item mk_comptest |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Makes tests for the CDBI Model. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=back |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub mk_compclass { |
|
38
|
0
|
|
|
0
|
1
|
|
my ( $self, $helper, $dsn, $user, $pass ) = @_; |
|
39
|
0
|
|
0
|
|
|
|
$helper->{dsn} = $dsn || ''; |
|
40
|
0
|
|
0
|
|
|
|
$helper->{user} = $user || ''; |
|
41
|
0
|
|
0
|
|
|
|
$helper->{pass} = $pass || ''; |
|
42
|
0
|
0
|
|
|
|
|
$helper->{rel} = $dsn =~ /sqlite|pg|mysql/i ? 1 : 0; |
|
43
|
0
|
|
|
|
|
|
my $file = $helper->{file}; |
|
44
|
0
|
|
|
|
|
|
$helper->{classes} = []; |
|
45
|
0
|
|
|
|
|
|
$helper->render_file( 'cdbiclass', $file ); |
|
46
|
|
|
|
|
|
|
#push( @{ $helper->{classes} }, $helper->{class} ); |
|
47
|
0
|
0
|
|
|
|
|
return 1 unless $dsn; |
|
48
|
0
|
|
|
|
|
|
my $loader = Class::DBI::Loader->new( |
|
49
|
|
|
|
|
|
|
dsn => $dsn, |
|
50
|
|
|
|
|
|
|
user => $user, |
|
51
|
|
|
|
|
|
|
password => $pass, |
|
52
|
|
|
|
|
|
|
namespace => $helper->{class} |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $path = $file; |
|
56
|
0
|
|
|
|
|
|
$path =~ s/\.pm$//; |
|
57
|
0
|
|
|
|
|
|
$helper->mk_dir($path); |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
for my $c ( $loader->classes ) { |
|
60
|
0
|
|
|
|
|
|
$helper->{tableclass} = $c; |
|
61
|
0
|
|
|
|
|
|
$helper->{tableclass} =~ /\W*(\w+)$/; |
|
62
|
0
|
|
|
|
|
|
my $f = $1; |
|
63
|
0
|
|
|
|
|
|
my $p = File::Spec->catfile( $path, "$f.pm" ); |
|
64
|
0
|
|
|
|
|
|
$helper->render_file( 'tableclass', $p ); |
|
65
|
0
|
|
|
|
|
|
push( @{ $helper->{classes} }, $c ); |
|
|
0
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
return 1; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub mk_comptest { |
|
71
|
0
|
|
|
0
|
1
|
|
my ( $self, $helper ) = @_; |
|
72
|
0
|
|
|
|
|
|
my $test = $helper->{test}; |
|
73
|
0
|
|
|
|
|
|
my $name = $helper->{name}; |
|
74
|
0
|
|
|
|
|
|
for my $c ( @{ $helper->{classes} } ) { |
|
|
0
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$helper->{tableclass} = $c; |
|
76
|
0
|
|
|
|
|
|
$helper->{tableclass} =~ /\:\:(\w+)\:\:(\w+)$/; |
|
77
|
0
|
|
|
|
|
|
my $prefix; |
|
78
|
0
|
0
|
|
|
|
|
unless ( $1 eq 'M' ) { $prefix = "$name\::$2" } |
|
|
0
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
else { $prefix = $2 } |
|
80
|
0
|
|
|
|
|
|
$prefix =~ s/::/-/g; |
|
81
|
0
|
|
|
|
|
|
my $test = $helper->next_test($prefix); |
|
82
|
0
|
|
|
|
|
|
$helper->render_file( 'test', $test ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, |
|
89
|
|
|
|
|
|
|
L<Catalyst::Response>, L<Catalyst::Helper> |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Sebastian Riedel, C<sri@oook.de> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 LICENSE |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
|
98
|
|
|
|
|
|
|
it under the same terms as perl itself. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
__DATA__ |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__cdbiclass__ |
|
106
|
|
|
|
|
|
|
package [% class %]; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
use strict; |
|
109
|
|
|
|
|
|
|
use base 'Catalyst::Model::CDBI'; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__PACKAGE__->config( |
|
112
|
|
|
|
|
|
|
dsn => '[% dsn %]', |
|
113
|
|
|
|
|
|
|
user => '[% user %]', |
|
114
|
|
|
|
|
|
|
password => '[% pass %]', |
|
115
|
|
|
|
|
|
|
options => {}, |
|
116
|
|
|
|
|
|
|
relationships => [% rel %] |
|
117
|
|
|
|
|
|
|
); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 NAME |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
[% class %] - CDBI Model Component |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
See L<[% app %]> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
CDBI Model Component. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
[% author %] |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 LICENSE |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
|
138
|
|
|
|
|
|
|
it under the same terms as perl itself. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
|
143
|
|
|
|
|
|
|
__tableclass__ |
|
144
|
|
|
|
|
|
|
package [% tableclass %]; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
use strict; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 NAME |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
[% tableclass %] - CDBI Table Class |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
See L<[% app %]> |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
CDBI Table Class. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
[% author %] |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 LICENSE |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
|
167
|
|
|
|
|
|
|
it under the same terms as perl itself. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |
|
172
|
|
|
|
|
|
|
__test__ |
|
173
|
|
|
|
|
|
|
use Test::More tests => 2; |
|
174
|
|
|
|
|
|
|
use_ok( Catalyst::Test, '[% app %]' ); |
|
175
|
|
|
|
|
|
|
use_ok('[% tableclass %]'); |