blib/lib/Catmandu/IdGenerator/Mock.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.6% 29 / 30 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Catmandu/Fix/random.pm ↑ Summary blib/lib/Catmandu/Fix/add_to_exporter.pm »
1 package Catmandu::IdGenerator::Mock;
2  
3 3 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '1.0201_02';
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Catmandu::Util qw(check_natural);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 with 'Catmandu::IdGenerator';
12  
13 has first_id =>
14 3 ▶ (is => 'ro', isa => sub {check_natural($_[0])}, default => sub {0},);
Subroutine __ANON__: called CC=1 SCAR=0.0
15  
16 2 has next_id =>
17 (is => 'rwp', init_arg => undef, lazy => 1, builder => 'first_id',);
18  
19 sub generate {
20 30 ▶ my ($self) = @_;
Subroutine generate: called CC=1 SCAR=0.0
Pod undocumented
21 30 my $id = $self->next_id;
22 30 $self->_set_next_id($id + 1);
23 30 $id;
24 }
25  
26 2 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
« blib/lib/Catmandu/Fix/random.pm ↑ Summary blib/lib/Catmandu/Fix/add_to_exporter.pm »