line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Prophet::UUIDGenerator; |
2
|
40
|
|
|
40
|
|
190
|
use Any::Moose; |
|
40
|
|
|
|
|
65
|
|
|
40
|
|
|
|
|
320
|
|
3
|
40
|
|
|
40
|
|
42173
|
use MIME::Base64::URLSafe; |
|
40
|
|
|
|
|
59173
|
|
|
40
|
|
|
|
|
2283
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#use UUID::Tiny; |
6
|
40
|
|
|
40
|
|
17668
|
use Prophet::TempUUIDTiny ':std'; |
|
40
|
|
|
|
|
105
|
|
|
40
|
|
|
|
|
25192
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# uuid_scheme: 1 - v1 and v3 uuids. |
10
|
|
|
|
|
|
|
# 2 - v4 and v5 uuids. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has uuid_scheme => ( |
13
|
|
|
|
|
|
|
isa => 'Int', |
14
|
|
|
|
|
|
|
is => 'rw' |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub create_str { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
0
|
0
|
|
|
|
|
if ($self->uuid_scheme == 1 ){ |
|
|
0
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return create_uuid_as_string(UUID_V1); |
22
|
|
|
|
|
|
|
} elsif ($self->uuid_scheme == 2) { |
23
|
0
|
|
|
|
|
|
return create_uuid_as_string(UUID_V4); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub create_string_from_url { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
0
|
|
|
|
|
|
my $url = shift; |
30
|
0
|
|
|
|
|
|
local $!; |
31
|
0
|
0
|
|
|
|
|
if ($self->uuid_scheme == 1 ){ |
|
|
0
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Yes, DNS, not URL. We screwed up when we first defined it |
33
|
|
|
|
|
|
|
# and it can't be safely changed once defined. |
34
|
0
|
|
|
|
|
|
create_uuid_as_string(UUID_V3, UUID_NS_DNS, $url); |
35
|
|
|
|
|
|
|
} elsif ($self->uuid_scheme == 2) { |
36
|
0
|
|
|
|
|
|
create_uuid_as_string(UUID_V5, UUID_NS_URL, $url); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub from_string { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my $str = shift; |
43
|
0
|
|
|
|
|
|
return string_to_uuid($str); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub to_string { |
47
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
48
|
0
|
|
|
|
|
|
my $uuid = shift; |
49
|
0
|
|
|
|
|
|
return uuid_to_string($uuid); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub from_safe_b64 { |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my $uuid = shift; |
55
|
0
|
|
|
|
|
|
return urlsafe_b64decode($uuid); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub to_safe_b64 { |
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $uuid = shift; |
61
|
0
|
|
|
|
|
|
return urlsafe_b64encode($self->from_string($uuid)); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub version { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
my $uuid = shift; |
67
|
0
|
|
|
|
|
|
return version_of_uuid($uuid); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub set_uuid_scheme { |
71
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
72
|
0
|
|
|
|
|
|
my $uuid = shift; |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($self->version($uuid) <= 3) { |
75
|
0
|
|
|
|
|
|
$self->uuid_scheme(1); |
76
|
|
|
|
|
|
|
} else { |
77
|
0
|
|
|
|
|
|
$self->uuid_scheme(2); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Foo::Bar |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
100
|
40
|
|
|
40
|
|
296
|
no Any::Moose; |
|
40
|
|
|
|
|
46
|
|
|
40
|
|
|
|
|
349
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|