line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
2
|
|
|
2
|
|
94478
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
14
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
2
|
|
|
2
|
|
13
|
use Catmandu::Util qw(check_natural); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
8
|
2
|
|
|
2
|
|
615
|
use namespace::clean; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
97
|
|
9
|
2
|
|
|
2
|
|
31
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::IdGenerator'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has first_id => |
13
|
|
|
|
|
|
|
(is => 'ro', isa => sub {check_natural($_[0])}, default => sub {0},); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has next_id => |
16
|
|
|
|
|
|
|
(is => 'rwp', init_arg => undef, lazy => 1, builder => 'first_id',); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
my $id = $self->next_id; |
20
|
30
|
|
|
30
|
0
|
1865
|
$self->_set_next_id($id + 1); |
21
|
30
|
|
|
|
|
377
|
$id; |
22
|
30
|
|
|
|
|
205
|
} |
23
|
30
|
|
|
|
|
71
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Catmandu::IdGenerator::Mock - Generator of increasing identifiers |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Catmandu::IdGenerator::Mock; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $x = Catmandu::IdGenerator::Mock->new(first_id => 10); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
for (1..100) { |
40
|
|
|
|
|
|
|
printf "id: %s\n" m $x->generate; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SEE ALSO |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This L<Catmandu::IdGenerator> generates identifiers based on the sequence of |
46
|
|
|
|
|
|
|
natural numbers. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 CONFIGURATION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item first_id |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
First number to start from. Set to C<0> by default (zero-based numbering). |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |