String/Random.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« String/Psv.pm ↑ Summary String/Regex.pm »
1 #
2 # $Id$
3 #
4 # string::random Brik
5 #
6 package Metabrik::String::Random;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::String::Password);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 attributes => {
19 datadir => [ qw(datadir) ],
20 },
21 attributes_default => {
22 charset => [ 'A'..'K', 'M'..'Z', 'a'..'k', 'm'..'z', 2..9, '_', '-' ],
23 length => 20,
24 count => 1,
25 },
26 commands => {
27 filename => [ qw(datadir|OPTIONAL) ],
28 },
29 };
30 }
31  
32 sub filename {
33 my $self = shift;
34 my ($datadir) = @_;
35  
36 $datadir ||= $self->datadir;
37  
38 my $random = $self->generate;
39  
40 return "$datadir/".$random->[0];
41 }
42  
43 1;
44  
45 __END__
« String/Psv.pm ↑ Summary String/Regex.pm »