| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Google::RestApi::Types; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# custom type constrants. see Type::Library. |
|
4
|
|
|
|
|
|
|
# NOTE: can't use Google::RestApi::Setup here because that module imports this one. |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
453402
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
31
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
45
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Types::Standard qw( Undef Str StrMatch Int ArrayRef HashRef Tuple HasMethods ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @types = qw( |
|
14
|
|
|
|
|
|
|
ReadableDir ReadableFile |
|
15
|
|
|
|
|
|
|
EmptyArrayRef EmptyHashRef |
|
16
|
|
|
|
|
|
|
EmptyString Zero False |
|
17
|
|
|
|
|
|
|
HasApi |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
3541
|
use Type::Library -base, -declare => @types; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
5
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
224
|
use Exporter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
460
|
|
|
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@types); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $meta = __PACKAGE__->meta; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$meta->add_type( |
|
29
|
|
|
|
|
|
|
name => 'ReadableDir', |
|
30
|
|
|
|
|
|
|
parent => Str->where( sub { -d -r; } ), |
|
31
|
|
|
|
|
|
|
message => sub { "Must point to a file system directory that's readable" }, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$meta->add_type( |
|
35
|
|
|
|
|
|
|
name => 'ReadableFile', |
|
36
|
|
|
|
|
|
|
parent => Str->where( sub { -f -r; } ), |
|
37
|
|
|
|
|
|
|
message => sub { "Must point to a file that's readable" }, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$meta->add_type( |
|
43
|
|
|
|
|
|
|
name => 'EmptyArrayRef', |
|
44
|
|
|
|
|
|
|
parent => ArrayRef->where( sub { scalar @$_ == 0; } ), |
|
45
|
|
|
|
|
|
|
message => sub { "Must be an empty array" }, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$meta->add_type( |
|
49
|
|
|
|
|
|
|
name => 'EmptyHashRef', |
|
50
|
|
|
|
|
|
|
parent => HashRef->where( sub { scalar keys %$_ == 0; } ), |
|
51
|
|
|
|
|
|
|
message => sub { "Must be an empty hash" }, |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $empty_string = $meta->add_type( |
|
55
|
|
|
|
|
|
|
name => 'EmptyString', |
|
56
|
|
|
|
|
|
|
parent => StrMatch[qr/^$/], |
|
57
|
|
|
|
|
|
|
message => sub { "Must be an empty string" }, |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $zero = $meta->add_type( |
|
61
|
|
|
|
|
|
|
name => 'Zero', |
|
62
|
|
|
|
|
|
|
parent => Int->where( sub { $_ == 0; } ), |
|
63
|
|
|
|
|
|
|
message => sub { "Must be an int equal to 0" }, |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# TODO: perhaps add emptyarray and emptyhash to this? |
|
67
|
|
|
|
|
|
|
my $false = $meta->add_type( |
|
68
|
|
|
|
|
|
|
name => 'False', |
|
69
|
|
|
|
|
|
|
parent => Undef | $zero | $empty_string, |
|
70
|
|
|
|
|
|
|
message => sub { "Must evaluate to false" }, |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$meta->add_type( |
|
76
|
|
|
|
|
|
|
name => 'HasApi', |
|
77
|
|
|
|
|
|
|
parent => HasMethods[qw(api)], |
|
78
|
|
|
|
|
|
|
message => sub { "Must be an api object"; } |
|
79
|
|
|
|
|
|
|
); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__PACKAGE__->make_immutable; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |