line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Types::ULID; |
2
|
|
|
|
|
|
|
$Types::ULID::VERSION = '0.004'; |
3
|
1
|
|
|
1
|
|
67049
|
use v5.10; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
544
|
use Type::Library -base; |
|
1
|
|
|
|
|
36747
|
|
|
1
|
|
|
|
|
13
|
|
8
|
1
|
|
|
1
|
|
881
|
use Types::Standard qw(Undef); |
|
1
|
|
|
|
|
74952
|
|
|
1
|
|
|
|
|
12
|
|
9
|
1
|
|
|
1
|
|
3038
|
use Types::Common::String qw(StrLength); |
|
1
|
|
|
|
|
61589
|
|
|
1
|
|
|
|
|
10
|
|
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
0
|
BEGIN { |
12
|
1
|
|
|
1
|
|
1118
|
my $has_xs = eval { require Data::ULID::XS; 1; }; |
|
1
|
|
|
|
|
166
|
|
|
0
|
|
|
|
|
0
|
|
13
|
1
|
50
|
|
|
|
7
|
my $backend = $has_xs ? 'Data::ULID::XS' : 'Data::ULID'; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
51
|
eval "require $backend"; |
16
|
1
|
|
|
|
|
8446
|
$backend->import(qw(ulid binary_ulid)); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
0
|
1553
|
sub ULID_BACKEND () { $backend } |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $tr_alphabet = '0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z'; |
22
|
|
|
|
|
|
|
my $ULID = Type::Tiny->new( |
23
|
|
|
|
|
|
|
name => 'ULID', |
24
|
|
|
|
|
|
|
parent => StrLength[26, 26], |
25
|
|
|
|
|
|
|
constraint => qq{ tr/$tr_alphabet// == 26 }, |
26
|
|
|
|
|
|
|
inlined => sub { |
27
|
|
|
|
|
|
|
my $varname = pop; |
28
|
|
|
|
|
|
|
return (undef, qq{ ($varname =~ tr/$tr_alphabet//) == 26 }); |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
coercion => [ |
32
|
|
|
|
|
|
|
Undef, q{ Types::ULID::ulid() }, |
33
|
|
|
|
|
|
|
], |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $BinaryULID = Type::Tiny->new( |
37
|
|
|
|
|
|
|
name => 'BinaryULID', |
38
|
|
|
|
|
|
|
parent => StrLength[16, 16], |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
coercion => [ |
41
|
|
|
|
|
|
|
Undef, q{ Types::ULID::binary_ulid() }, |
42
|
|
|
|
|
|
|
], |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__PACKAGE__->add_type($ULID); |
46
|
|
|
|
|
|
|
__PACKAGE__->add_type($BinaryULID); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->make_immutable; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |