File Coverage

blib/lib/Crypt/HSXKPasswd/RNG.pm
Criterion Covered Total %
statement 32 34 94.1
branch n/a
condition n/a
subroutine 11 13 84.6
pod 0 2 0.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package Crypt::HSXKPasswd::RNG;
2              
3             # import required modules
4 3     3   1237 use strict;
  3         5  
  3         98  
5 3     3   14 use warnings;
  3         5  
  3         96  
6 3     3   13 use Carp; # for nicer 'exception' handling for users of the module
  3         5  
  3         236  
7 3     3   18 use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
  3         3  
  3         20  
8 3     3   4538 use English qw( -no_match_vars ); # for more readable code
  3         5  
  3         19  
9 3     3   2645 use Readonly; # for truly constant constants
  3         5  
  3         222  
10 3     3   20 use Crypt::HSXKPasswd::Helper; # exports utility functions like _error & _warn
  3         4  
  3         255  
11              
12             # set things up for using UTF-8
13 3     3   75 use 5.016; # min Perl for good UTF-8 support, implies feature 'unicode_strings'
  3         21  
14 3     3   16 use Encode qw(encode decode);
  3         5  
  3         234  
15 3     3   18 use utf8;
  3         5  
  3         25  
16             binmode STDOUT, ':encoding(UTF-8)';
17              
18             # Copyright (c) 2015, Bart Busschots T/A Bartificer Web Solutions All rights
19             # reserved.
20             #
21             # Code released under the FreeBSD license (included in the POD at the bottom of
22             # HSXKPasswd.pm)
23              
24             #
25             # --- Constants ---------------------------------------------------------------
26             #
27              
28             # version info
29 3     3   162 use version; our $VERSION = qv('1.2');
  3         10  
  3         16  
30              
31             # utility variables
32             Readonly my $_CLASS => __PACKAGE__;
33              
34             #
35             # --- Constructor -------------------------------------------------------------
36             #
37              
38             #####-SUB-#####################################################################
39             # Type : CONSTRUCTOR (CLASS)
40             # Purpose : A place-holder for the constructor - just throws an error
41             # Returns : VOID
42             # Arguments : NONE
43             # Throws : ALWAYS throws an error to say this class must be extended.
44             # Notes :
45             # See Also :
46             ## no critic (Subroutines::RequireFinalReturn);
47             sub new{
48 0     0 0   _error("$_CLASS must be extended to be used");
49             }
50             ## use critic
51              
52             #
53             # --- Public Instance functions -----------------------------------------------
54             #
55              
56             #####-SUB-#####################################################################
57             # Type : INSTANCE
58             # Purpose : A place-holder for the function to get n random numbers.
59             # Returns : NOTHING - but in subclasses should return an array of random
60             # numbers between 0 and 1.
61             # Arguments : 1) the number of random numbers needed to generate a single
62             # password.
63             # Throws : ALWAYS throws an error to say this class must be extended, and
64             # this function must be overridden.
65             # Notes :
66             # See Also :
67             ## no critic (Subroutines::RequireFinalReturn);
68             sub random_numbers{
69 0     0 0   _error("$_CLASS must be extended to be used, and the function random_numbers() must be overridden");
70             }
71             ## use critic
72              
73             1; # because Perl is just a little bit odd :)