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   113 use strict;
  22         34  
  22         861  
2 22     22   96 use warnings;
  22         40  
  22         1526  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.042000';
6 22     22   14065 use Type::Tiny ();
  22         570554  
  22         690  
7 22     22   13698 use Types::Standard ();
  22         1864062  
  22         1082  
8 22     22   548 use Ref::Util qw< is_ref >;
  22         554  
  22         1531  
9              
10 22     22   9140 use parent 'Exporter';
  22         6176  
  22         146  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 107     107 1 622 sub Str { Types::Standard::Str }
14 64     64 1 306 sub Int { Types::Standard::Int }
15 42     42 1 233 sub ArrayRef { Types::Standard::ArrayRef }
16 64     64 1 392 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   2403 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 272 );
25             }
26              
27             1;
28              
29             __END__