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   178 use strict;
  23         57  
  23         1135  
2 23     23   141 use warnings;
  23         44  
  23         2016  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.040000';
6 23     23   23812 use Type::Tiny ();
  23         777878  
  23         792  
7 23     23   17097 use Types::Standard ();
  23         2570503  
  23         1371  
8 23     23   815 use Ref::Util qw< is_ref >;
  23         803  
  23         1965  
9              
10 23     23   12354 use parent 'Exporter';
  23         7632  
  23         181  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 112     112 1 772 sub Str { Types::Standard::Str }
14 67     67 1 377 sub Int { Types::Standard::Int }
15 44     44 1 297 sub ArrayRef { Types::Standard::ArrayRef }
16 67     67 1 435 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   2989 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 367 );
25             }
26              
27             1;
28              
29             __END__