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 22     22   104 use strict;
  22         32  
  22         835  
2 22     22   100 use warnings;
  22         27  
  22         1240  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.041000';
6 22     22   13354 use Type::Tiny ();
  22         500537  
  22         573  
7 22     22   13699 use Types::Standard ();
  22         1922374  
  22         1120  
8 22     22   609 use Ref::Util qw< is_ref >;
  22         523  
  22         1575  
9              
10 22     22   9616 use parent 'Exporter';
  22         6034  
  22         127  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 107     107 1 629 sub Str { Types::Standard::Str }
14 64     64 1 297 sub Int { Types::Standard::Int }
15 42     42 1 266 sub ArrayRef { Types::Standard::ArrayRef }
16 64     64 1 370 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   2244 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 22     22 1 336 );
25             }
26              
27             1;
28              
29             __END__