File Coverage

blib/lib/MetaCPAN/Client/Types.pm
Criterion Covered Total %
statement 24 26 92.3
branch 1 2 50.0
condition n/a
subroutine 12 14 85.7
pod 6 6 100.0
total 43 48 89.5


line stmt bran cond sub pod time code
1 23     23   150 use strict;
  23         35  
  23         885  
2 23     23   100 use warnings;
  23         41  
  23         1549  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.044000';
6 23     23   15687 use Type::Tiny ();
  23         617088  
  23         685  
7 23     23   15676 use Types::Standard ();
  23         2108597  
  23         1136  
8 23     23   666 use Ref::Util qw< is_ref >;
  23         531  
  23         1549  
9              
10 23     23   10149 use parent 'Exporter';
  23         6373  
  23         131  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 112     112 1 677 sub Str { Types::Standard::Str }
14 67     67 1 362 sub Int { Types::Standard::Int }
15 44     44 1 262 sub ArrayRef { Types::Standard::ArrayRef }
16 67     67 1 428 sub HashRef { Types::Standard::HashRef }
17 0     0 1 0 sub Bool { Types::Standard::Bool }
18              
19             sub Time {
20             return Type::Tiny->new(
21             name => "Time",
22 11 50   11   2812 constraint => sub { !is_ref($_) and /^[1-9][0-9]*(?:s|m|h)$/ },
23 0     0   0 message => sub { "$_ is not in time format (e.g. '5m')" },
24 23     23 1 321 );
25             }
26              
27             1;
28              
29             __END__