line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Types::ULID; |
2
|
|
|
|
|
|
|
$Types::ULID::VERSION = '0.003'; |
3
|
1
|
|
|
1
|
|
72069
|
use v5.10; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
652
|
use Type::Library -base; |
|
1
|
|
|
|
|
38977
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
1122
|
use Types::Standard qw(Undef); |
|
1
|
|
|
|
|
77398
|
|
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
3212
|
use Types::Common::String qw(StrLength); |
|
1
|
|
|
|
|
64347
|
|
|
1
|
|
|
|
|
12
|
|
10
|
1
|
|
|
1
|
|
1702
|
use Data::ULID; |
|
1
|
|
|
|
|
9322
|
|
|
1
|
|
|
|
|
80
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
13
|
use constant HAS_XS => eval { require Data::ULID::XS; 1; }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
403
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $tr_alphabet = '0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z'; |
15
|
|
|
|
|
|
|
my $ULID = Type::Tiny->new( |
16
|
|
|
|
|
|
|
name => 'ULID', |
17
|
|
|
|
|
|
|
parent => StrLength[26, 26], |
18
|
|
|
|
|
|
|
constraint => qq{ tr/$tr_alphabet// == 26 }, |
19
|
|
|
|
|
|
|
inlined => sub { |
20
|
|
|
|
|
|
|
my $varname = pop; |
21
|
|
|
|
|
|
|
return (undef, qq{ ($varname =~ tr/$tr_alphabet//) == 26 }); |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
coercion => [ |
25
|
|
|
|
|
|
|
Undef, HAS_XS ? q{ Data::ULID::XS::ulid() } : q{ Data::ULID::ulid() }, |
26
|
|
|
|
|
|
|
], |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $BinaryULID = Type::Tiny->new( |
30
|
|
|
|
|
|
|
name => 'BinaryULID', |
31
|
|
|
|
|
|
|
parent => StrLength[16, 16], |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
coercion => [ |
34
|
|
|
|
|
|
|
Undef, HAS_XS ? q{ Data::ULID::XS::binary_ulid() } : q{ Data::ULID::binary_ulid() }, |
35
|
|
|
|
|
|
|
], |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->add_type($ULID); |
39
|
|
|
|
|
|
|
__PACKAGE__->add_type($BinaryULID); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__PACKAGE__->make_immutable; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |