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   117 use strict;
  21         35  
  21         504  
2 21     21   99 use warnings;
  21         28  
  21         744  
3             package MetaCPAN::Client::Types;
4             # ABSTRACT: type checking helper class
5             $MetaCPAN::Client::Types::VERSION = '2.030000';
6 21     21   10952 use Type::Tiny ();
  21         280727  
  21         585  
7 21     21   11879 use Types::Standard ();
  21         1013018  
  21         789  
8 21     21   643 use Ref::Util qw< is_ref >;
  21         491  
  21         967  
9              
10 21     21   7713 use parent 'Exporter';
  21         5573  
  21         141  
11             our @EXPORT_OK = qw< Str Int Time ArrayRef HashRef Bool >;
12              
13 103     103 1 375 sub Str { Types::Standard::Str }
14 40     40 1 187 sub Int { Types::Standard::Int }
15 41     41 1 212 sub ArrayRef { Types::Standard::ArrayRef }
16 61     61 1 250 sub HashRef { Types::Standard::HashRef }
17 21     21 1 110 sub Bool { Types::Standard::Bool }
18              
19             sub Time {
20             return Type::Tiny->new(
21             name => "Time",
22 11 50   11   2251 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 204 );
25             }
26              
27             1;
28              
29             __END__