File Coverage

blib/lib/CMS/Drupal/Types.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package CMS::Drupal::Types;
2             $CMS::Drupal::Types::VERSION = '0.091';
3             # ABSTRACT: A Perl type library for working with Drupal
4              
5 2     2   11 use strict;
  2         3  
  2         94  
6 2     2   12 use warnings;
  2         4  
  2         74  
7 2     2   62 use 5.010;
  2         5  
  2         131  
8              
9 2         18 use Type::Library -base, -declare => qw/ DBName
10             DBDriver
11             DBUsername
12             DBPassword
13             DBHost
14             DBPort
15 2     2   27 DBPrefix /;
  2         4  
16 2     2   3804 use Type::Utils qw/ :all /;
  2         10403  
  2         21  
17 2     2   6453 use Types::Standard qw/ Optional Maybe Str StrMatch Int slurpy Dict /;
  2         5  
  2         17  
18              
19             declare DBName, as Str, where { length > 0 },
20             message { 'You must supply the database name. ' };
21              
22             declare DBDriver, as StrMatch[ qr{ ^(mysql|Pg|SQLite)$ }x ],
23             message { 'You must supply the name of a valid installed dbi:dbd driver (mysql, Pg, or SQLite). ' };
24              
25             declare DBUsername, as Optional[Str],
26             message { 'The username must be a string. ' };
27              
28             declare DBPassword, as Optional[Str],
29             message { 'The password must be a string. ' };
30              
31             declare DBHost, as Optional[Str],
32             message { 'The hostname must be a string. ' };
33              
34             declare DBPort, as Optional[Int],
35             message { 'The port number must be an integer. ' };
36              
37             declare DBPrefix, as Optional[StrMatch[ qr/ \w+_ /x ]],
38             message { return 'The table prefix must end in an underscore. ' };
39              
40             1; ## return true to end package CMS::Drupal::Types
41             __END__