line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Helper::Model::Redis; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3740
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Catalyst::Model::Redis - Redis Model Class |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
0.01 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
create model Redis Redis -- --host localhost --port 6379 --utf8 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 USAAGE |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
You can specify following configuration options: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item B<--host> I<hostname> |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item B<--port> I<port> |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item B<--database> I<db> |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item B<--password> I<password> |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item B<--lazy> |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item B<--utf8> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=back |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
See description of options in L<RedisDB> documentation. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 $self->mk_compclass |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Creates model class |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
1
|
|
1139
|
use Getopt::Long qw(GetOptionsFromArray); |
|
1
|
|
|
|
|
11608
|
|
|
1
|
|
|
|
|
6
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub mk_compclass { |
54
|
0
|
|
|
0
|
1
|
|
my ( $class, $helper, @args ) = @_; |
55
|
0
|
|
|
|
|
|
my %conf; |
56
|
0
|
0
|
|
|
|
|
GetOptionsFromArray( |
57
|
|
|
|
|
|
|
\@args, |
58
|
|
|
|
|
|
|
"host=s" => \$conf{host}, |
59
|
|
|
|
|
|
|
"port=i" => \$conf{port}, |
60
|
|
|
|
|
|
|
"path=s" => \$conf{path}, |
61
|
|
|
|
|
|
|
"database=i" => \$conf{database}, |
62
|
|
|
|
|
|
|
"password=s" => \$conf{password}, |
63
|
|
|
|
|
|
|
"utf8" => \$conf{utf8}, |
64
|
|
|
|
|
|
|
"lazy" => \$conf{lazy}, |
65
|
|
|
|
|
|
|
) or die "Invalid options for model"; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
1559
|
use Data::Dumper; |
|
1
|
|
|
|
|
6403
|
|
|
1
|
|
|
|
|
210
|
|
68
|
0
|
|
|
|
|
|
warn Dumper [ \%conf ]; |
69
|
0
|
|
|
|
|
|
my $file = $helper->{file}; |
70
|
0
|
|
|
|
|
|
$helper->render_file( 'modelclass', $file, { conf => \%conf } ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 $self->mk_comptest |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
creates test for model class |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub mk_comptest { |
80
|
0
|
|
|
0
|
1
|
|
my ( $self, $helper ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$helper->render_file( 'modeltest', $helper->{test} ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SEE ALSO |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L<Catalyst>, L<RedisDB> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 BUGS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Please report any bugs or feature requests via GitHub bug tracker at |
94
|
|
|
|
|
|
|
L<http://github.com/trinitum/perl-Catalyst-Model-Redis/issues>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Pavel Shaydo C<< <zwon at cpan.org> >> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (C) 2012 Pavel Shaydo |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
105
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
106
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__DATA__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=begin ignore |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__modelclass__ |
117
|
|
|
|
|
|
|
package [% class %]; |
118
|
|
|
|
|
|
|
use strict; |
119
|
|
|
|
|
|
|
use warnings; |
120
|
|
|
|
|
|
|
use base 'Catalyst::Model::Redis'; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__PACKAGE__->config( |
123
|
|
|
|
|
|
|
[% FOR param IN conf -%] |
124
|
|
|
|
|
|
|
[% IF param.value %] [% param.key %] => "[% param.value %]", |
125
|
|
|
|
|
|
|
[% END %] |
126
|
|
|
|
|
|
|
[%- END -%] |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 NAME |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
[% class %] - Redis Catalyst model |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DESCRIPTION |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Redis Catalyst model component. See L<Catalyst::Model::Redis> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__modeltest__ |
140
|
|
|
|
|
|
|
use strict; |
141
|
|
|
|
|
|
|
use warnings; |
142
|
|
|
|
|
|
|
use Test::More tests => 2; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
use_ok('Catalyst::Test', '[% app %]'); |
145
|
|
|
|
|
|
|
use_ok('[% class %]'); |