line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Bag::IdGenerator; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
9964
|
use Catmandu::Sane; |
|
20
|
|
|
|
|
58
|
|
|
20
|
|
|
|
|
144
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
20
|
|
|
20
|
|
164
|
use Moo::Role; |
|
20
|
|
|
|
|
56
|
|
|
20
|
|
|
|
|
144
|
|
8
|
20
|
|
|
20
|
|
7618
|
use namespace::clean; |
|
20
|
|
|
|
|
45
|
|
|
20
|
|
|
|
|
123
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::IdGenerator'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__END__ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Catmandu::Bag::IdGenerator - A base role for bag identifier generators |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package MyGenerator; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Moo; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
with 'Catmandu::Bag::IdGenerator'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub generate { |
31
|
|
|
|
|
|
|
my ($self, $bag) = @_; |
32
|
|
|
|
|
|
|
return $bag->name . "-" . int(ran(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 |
49
|
|
|
|
|
|
|
|