blib/lib/Catalyst/Plugin/Session/Store/CHI/CHI.pm

filter: Statementstmt 57.1% 32 / 56 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 58.8% 10 / 17 Podpod 100% 5 / 5 totaltotal 50.5% 47 / 93 CC 7 SCAR 28.9
CC
7
Cov
48%
_check_session_chi_chi_storage
56.0
get_session_data
2.0
store_session_data
2.0
CRAP 18.0
↑ Summary
1 package Catalyst::Plugin::Session::Store::CHI::CHI;
2  
3 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use base qw( Class::Data::Inheritable Catalyst::Plugin::Session::Store );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use CHI;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Path::Class ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Catalyst::Utils ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 __PACKAGE__->mk_classdata(qw/_session_chi_chi_storage/);
18  
19 =head1 NAME
20  
21 Catalyst::Plugin::Session::Store::CHI::CHI - The great new Catalyst::Plugin::Session::Store::CHI::CHI!
22  
23 =head1 VERSION
24  
25 Version 0.001_003
26  
27 =cut
28  
29 2 our $VERSION = '0.001_003';
30  
31 =head1 SYNOPSIS
32  
33 Quick summary of what the module does.
34  
35 Perhaps a little code snippet.
36  
37 use Catalyst::Plugin::Session::Store::CHI::CHI;
38  
39 my $foo = Catalyst::Plugin::Session::Store::CHI::CHI->new();
40 ...
41  
42 =head1 EXPORT
43  
44 A list of functions that can be exported. You can delete this section
45 if you don't export anything, such as for a purely object-oriented module.
46  
47 =head1 SUBROUTINES/METHODS
48  
49 =head2 METHODS
50  
51 =over 4
52  
53 =item get_session_data
54  
55 =item store_session_data
56  
57 =item delete_session_data
58  
59 =item delete_expired_sessions
60  
61 These are implementations of the required methods for a store. See
62 L<Catalyst::Plugin::Session::Store>.
63  
64 =cut
65  
66 sub get_session_data {
67 0 ▶ my ( $c, $sid ) = @_;
Subroutine get_session_data: not called CC=1 SCAR=6.9
Pod documented
68 0 $c->_check_session_chi_chi_storage; #see?
69 0 return $c->_session_chi_chi_storage->get($sid);
70 }
71  
72 sub store_session_data {
73 0 ▶ my ( $c, $sid, $data ) = @_;
Subroutine store_session_data: not called CC=1 SCAR=6.9
Pod documented
74 0 $c->_check_session_chi_chi_storage; #see?
75 0 return $c->_session_chi_chi_storage->set( $sid, $data );
76 }
77  
78 sub delete_session_data {
79 0 ▶ my ( $c, $sid ) = @_;
Subroutine delete_session_data: not called CC=1 SCAR=6.9
Pod documented
80 0 $c->_check_session_chi_chi_storage; #see?
81 0 return $c->_session_chi_chi_storage->remove($sid);
82 }
83  
84 0 ▶sub delete_expired_sessions { return; } # unsupported
Subroutine delete_expired_sessions: not called CC=1 SCAR=6.9
Pod documented
85  
86 # Dummy method.
87 ## no critic (ProhibitUnusedPrivateSubroutines)
88 sub _session_store_delegate {
89 0 ▶ my ($self) = @_;
Subroutine _session_store_delegate: not called CC=1 SCAR=6.9
90 0 return 1;
91 }
92 ## use critic
93  
94 =item setup_session
95  
96 Sets up the session cache file.
97  
98 =back
99  
100 =cut
101  
102 sub setup_session {
103 0 ▶ my $c = shift;
Subroutine setup_session: not called CC=1 SCAR=6.9
Pod documented
104  
105 0 return $c->maybe::next::method(@_);
106 }
107  
108 sub _check_session_chi_chi_storage {
109 0 ▶ my $c = shift;
Subroutine _check_session_chi_chi_storage: not called CC=7 SCAR=40.3
110 0 ▶ return if $c->_session_chi_chi_storage;
Branch: 1 branch
BranchTrueFalseTotal
if $c->_session_chi_chi_storage 0 0 0
111  
112 0 ▶ $c->_session_plugin_config->{namespace} ||= 'SessionStoreChiChi';
Condition0%0/2
$c->_session_plugin_config->{"namespace"} ||= "SessionStoreChiChi"
l!l
00
MC/DC0%0/1
$c->_session_plugin_config->{"namespace"} ||= "SessionStoreChiChi"
$c->_session_plugin_config->{"namespace"}
Truth table0%0/2
A
A= $c->_session_plugin_config->{"namespace"}
Aresult
11
00
113 0 ▶ my $cfg = $c->_session_plugin_config->{chi_chi} || {};
Condition0%0/2
$c->_session_plugin_config->{'chi_chi'} || {}
l!l
00
MC/DC0%0/1
$c->_session_plugin_config->{'chi_chi'} || {}
$c->_session_plugin_config->{'chi_chi'}
Truth table0%0/2
A
A= $c->_session_plugin_config->{'chi_chi'}
Aresult
11
00
114 0 ▶ $cfg->{expires_in} ||= $c->_session_plugin_config->{expires};
Condition0%0/3
$cfg->{"expires_in"} ||= $c->_session_plugin_config->{"expires"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cfg->{"expires_in"} ||= $c->_session_plugin_config->{"expires"}
$cfg->{"expires_in"} $c->_session_plugin_config->{"expires"}
Truth table0%0/3
A ||= B
A= $cfg->{"expires_in"}B= $c->_session_plugin_config->{"expires"}
ABresult
1X1
011
000
115  
116 0 ▶ if ( $cfg->{dbic_class} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{"dbic_class"}) 0 0 0
117 0 $cfg->{resultset} = $c->model( $cfg->{dbic_class} );
118 }
119  
120 0 for my $k (qw/driver /) {
121 0 assert( $cfg->{$k}, "Need session config key $k" );
122 }
123  
124 0 return $c->_session_chi_chi_storage( CHI->new(%$cfg) );
125 }
126  
127 =head1 AUTHOR
128  
129 Motortrak Ltd, C<< <duncan.garland at motortrak.com> >>
130  
131 =head1 BUGS
132  
133 Please report any bugs or feature requests to C<bug-catalyst-plugin-session-store-chi-chi at rt.cpan.org>, or through
134 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-Session-Store-CHI-CHI>. I will be notified, and then you'll
135 automatically be notified of progress on your bug as I make changes.
136  
137  
138  
139  
140 =head1 SUPPORT
141  
142 You can find documentation for this module with the perldoc command.
143  
144 perldoc Catalyst::Plugin::Session::Store::CHI::CHI
145  
146  
147 You can also look for information at:
148  
149 =over 4
150  
151 =item * RT: CPAN's request tracker (report bugs here)
152  
153 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-Session-Store-CHI-CHI>
154  
155 =item * AnnoCPAN: Annotated CPAN documentation
156  
157 L<http://annocpan.org/dist/Catalyst-Plugin-Session-Store-CHI-CHI>
158  
159 =item * CPAN Ratings
160  
161 L<http://cpanratings.perl.org/d/Catalyst-Plugin-Session-Store-CHI-CHI>
162  
163 =item * Search CPAN
164  
165 L<http://search.cpan.org/dist/Catalyst-Plugin-Session-Store-CHI-CHI/>
166  
167 =back
168  
169  
170 =head1 ACKNOWLEDGEMENTS
171  
172  
173 =head1 LICENSE AND COPYRIGHT
174  
175 Copyright 2014 Motortrak Ltd.
176  
177 This program is free software; you can redistribute it and/or modify it
178 under the terms of the the Artistic License (2.0). You may obtain a
179 copy of the full license at:
180  
181 L<http://www.perlfoundation.org/artistic_license_2_0>
182  
183 Any use, modification, and distribution of the Standard or Modified
184 Versions is governed by this Artistic License. By using, modifying or
185 distributing the Package, you accept this license. Do not use, modify,
186 or distribute the Package, if you do not accept this license.
187  
188 If your Modified Version has been derived from a Modified Version made
189 by someone other than you, you are nevertheless required to ensure that
190 your Modified Version complies with the requirements of this license.
191  
192 This license does not grant you the right to use any trademark, service
193 mark, tradename, or logo of the Copyright Holder.
194  
195 This license includes the non-exclusive, worldwide, free-of-charge
196 patent license to make, have made, use, offer to sell, sell, import and
197 otherwise transfer the Package with respect to any patent claims
198 licensable by the Copyright Holder that are necessarily infringed by the
199 Package. If you institute patent litigation (including a cross-claim or
200 counterclaim) against any party alleging that the Package constitutes
201 direct or contributory patent infringement, then this Artistic License
202 to you shall terminate on the date that such litigation is filed.
203  
204 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
205 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
206 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
207 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
208 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
209 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
210 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
211 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
212  
213  
214 =cut
215  
216 2 1; # End of Catalyst::Plugin::Session::Store::CHI::CHI
↑ Summary