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