File Coverage

blib/lib/MetaCPAN/Client/Types.pm
Criterion Covered Total %
statement 25 26 96.1
branch 1 2 50.0
condition n/a
subroutine 13 14 92.8
pod 6 6 100.0
total 45 48 93.7


line stmt bran cond sub pod time code
1 21     21   146 use strict;
  21         41  
  21         614  
2 21     21   107 use warnings;
  21         40  
  21         1006  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.028000';
6 21     21   12951 use Type::Tiny ();
  21         337056  
  21         695  
7 21     21   12622 use Types::Standard ();
  21         1233069  
  21         1011  
8 21     21   866 use Ref::Util qw< is_ref >;
  21         642  
  21         1202  
9              
10 21     21   9804 use parent 'Exporter';
  21         6866  
  21         134  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 103     103 1 450 sub Str { Types::Standard::Str }
14 40     40 1 246 sub Int { Types::Standard::Int }
15 41     41 1 312 sub ArrayRef { Types::Standard::ArrayRef }
16 61     61 1 319 sub HashRef { Types::Standard::HashRef }
17 21     21 1 133 sub Bool { Types::Standard::Bool }
18              
19             sub Time {
20             return Type::Tiny->new(
21             name => "Time",
22 11 50   11   2750 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 21     21 1 286 );
25             }
26              
27             1;
28              
29             __END__