File Coverage

blib/lib/Data/Session/ID/UUID34.pm
Criterion Covered Total %
statement 26 28 92.8
branch n/a
condition 1 2 50.0
subroutine 9 10 90.0
pod 1 4 25.0
total 37 44 84.0


line stmt bran cond sub pod time code
1             package Data::Session::ID::UUID34;
2              
3 1     1   1083 use parent 'Data::Session::ID';
  1         2  
  1         10  
4 1     1   281 no autovivification;
  1         2  
  1         10  
5 1     1   121 use strict;
  1         2  
  1         112  
6 1     1   6 use warnings;
  1         2  
  1         110  
7              
8 1     1   851 use Data::UUID;
  1         1894  
  1         156  
9              
10 1     1   9 use Hash::FieldHash ':all';
  1         2  
  1         899  
11              
12             our $VERSION = '1.16';
13              
14             # -----------------------------------------------
15              
16             sub generate
17             {
18 15     15 0 26 my($self) = @_;
19              
20 15         4799 return Data::UUID -> new -> create_hex;
21              
22             } # End of generate.
23              
24             # -----------------------------------------------
25              
26             sub id_length
27             {
28 0     0 0 0 my($self) = @_;
29              
30 0         0 return 34;
31              
32             } # End of id_length.
33              
34             # -----------------------------------------------
35              
36             sub init
37             {
38 30     30 0 46 my($self, $arg) = @_;
39 30         66 $$arg{id_length} = 34; # Bytes.
40 30   50     130 $$arg{verbose} ||= 0;
41              
42             } # End of init.
43              
44             # -----------------------------------------------
45              
46             sub new
47             {
48 30     30 1 376 my($class, %arg) = @_;
49              
50 30         114 $class -> init(\%arg);
51              
52 30         2682 return from_hash(bless({}, $class), \%arg);
53              
54             } # End of new.
55              
56             # -----------------------------------------------
57              
58             1;
59              
60             =pod
61              
62             =head1 NAME
63              
64             L - A persistent session manager
65              
66             =head1 Synopsis
67              
68             See L for details.
69              
70             =head1 Description
71              
72             L allows L to generate session ids using L.
73              
74             To use this module do this:
75              
76             =over 4
77              
78             =item o Specify an id generator of type UUID34, as Data::Session -> new(type => '... id:UUID34 ...')
79              
80             =back
81              
82             =head1 Case-sensitive Options
83              
84             See L for important information.
85              
86             =head1 Method: new()
87              
88             Creates a new object of type L.
89              
90             C takes a hash of key/value pairs, some of which might mandatory. Further, some combinations
91             might be mandatory.
92              
93             The keys are listed here in alphabetical order.
94              
95             They are lower-case because they are (also) method names, meaning they can be called to set or get the value
96             at any time.
97              
98             =over 4
99              
100             =item o verbose => $integer
101              
102             Print to STDERR more or less information.
103              
104             Typical values are 0, 1 and 2.
105              
106             This key is normally passed in as Data::Session -> new(verbose => $integer).
107              
108             This key is optional.
109              
110             =back
111              
112             =head1 Method: generate()
113              
114             Generates the next session id, or dies if it can't.
115              
116             The algorithm is Data::UUID -> new -> create_hex.
117              
118             Returns the new id.
119              
120             Note: L returns '0x' as the prefix of the 34-byte hex digest. You have been warned.
121              
122             =head1 Method: id_length()
123              
124             Returns 34 because that's the number of bytes in a UUID34 digest.
125              
126             This can be used to generate the SQL to create the sessions table.
127              
128             See scripts/digest.pl.
129              
130             =head1 Support
131              
132             Log a bug on RT: L.
133              
134             =head1 Author
135              
136             L was written by Ron Savage Iron@savage.net.auE> in 2010.
137              
138             Home page: L.
139              
140             =head1 Copyright
141              
142             Australian copyright (c) 2010, Ron Savage.
143              
144             All Programs of mine are 'OSI Certified Open Source Software';
145             you can redistribute them and/or modify them under the terms of
146             The Artistic License, a copy of which is available at:
147             http://www.opensource.org/licenses/index.html
148              
149             =cut