line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::IdGenerator; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
11799
|
use Catmandu::Sane; |
|
22
|
|
|
|
|
63
|
|
|
22
|
|
|
|
|
205
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
22
|
|
|
22
|
|
176
|
use Moo::Role; |
|
22
|
|
|
|
|
49
|
|
|
22
|
|
|
|
|
157
|
|
8
|
22
|
|
|
22
|
|
8670
|
use namespace::clean; |
|
22
|
|
|
|
|
55
|
|
|
22
|
|
|
|
|
153
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'generate'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__END__ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Catmandu::IdGenerator - A base role for identifier generators |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package MyGenerator; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Moo; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
with 'Catmandu::IdGenerator'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub generate { |
31
|
|
|
|
|
|
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
return int(rand(999999)) . "-" . time; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package main; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $gen = MyGenerator->new; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
for (1..100) { |
40
|
|
|
|
|
|
|
printf "id: %s\n" m $gen->generate; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SEE ALSO |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L<Catmandu::IdGenerator::Mock> , |
46
|
|
|
|
|
|
|
L<Catmandu::IdGenerator::UUID> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |