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.090';
3             # ABSTRACT: A Perl type library for working with Drupal
4              
5 2     2   8 use strict;
  2         2  
  2         76  
6 2     2   10 use warnings;
  2         4  
  2         72  
7 2     2   52 use 5.010;
  2         6  
  2         121  
8              
9 2         18 use Type::Library -base, -declare => qw/ DBName
10             DBDriver
11             DBUsername
12             DBPassword
13             DBHost
14             DBPort
15 2     2   15 DBPrefix /;
  2         2  
16 2     2   2599 use Type::Utils qw/ :all /;
  2         7444  
  2         19  
17 2     2   5026 use Types::Standard qw/ Optional Maybe Str StrMatch Int slurpy Dict /;
  2         4  
  2         10  
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__