blib/lib/Catmandu/Fix/sleep.pm

filter: Statementstmt 90.3% 28 / 31 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 83.3% 40 / 48 CC 6 SCAR 14.9
CC
6
Cov
83%
fix
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« blib/lib/Catmandu/Iterable.pm ↑ Summary blib/lib/Catmandu/Cmd.pm »
1 package Catmandu::Fix::sleep;
2  
3 2 ▶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 Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 with 'Catmandu::Fix::Inlineable';
13  
14 2 has seconds => (fix_arg => 1);
15 2 has units => (fix_arg => 1);
16  
17 sub fix {
18 4 ▶ my ($self, $data) = @_;
Subroutine fix: called CC=6 SCAR=19.9
Pod undocumented
19  
20 4 my $sleep = $self->seconds;
21 4 my $units = $self->units;
22  
23 4 ▶ if ($units =~ /^MICROSECOND(S)?$/i) { }
Branch: 5 branches
BranchTrueFalseTotal
if ($units =~ /^MICROSECOND(S)?$/i) { } 0 4 4
elsif ($units =~ /^MILLISECOND(S)$/i) { } 0 4 4
elsif ($units =~ /^SECOND(S)?$/i) { } 3 1 4
elsif ($units =~ /^MINUTE(S)?$/i) { } 0 1 1
elsif ($units =~ /^HOUR(S)?$/i) { } 0 1 1
24 elsif ($units =~ /^MILLISECOND(S)$/i) {
25 0 $sleep *= 1000;
26 }
27 elsif ($units =~ /^SECOND(S)?$/i) {
28 3 $sleep *= 1000000;
29 }
30 elsif ($units =~ /^MINUTE(S)?$/i) {
31 0 $sleep *= 60 * 1000000;
32 }
33 elsif ($units =~ /^HOUR(S)?$/i) {
34 0 $sleep *= 3600 * 1000000;
35 }
36 else {
37 1 $sleep *= 1000000;
38 }
39  
40 4 Time::HiRes::usleep($sleep);
41  
42 4 $data;
43 }
44  
45 2 1;
46  
47 __END__
48  
49 =pod
50  
51 =head1 NAME
52  
53 Catmandu::Fix::sleep - Do nothing for a specified amount of time
54  
55 =head1 SYNOPSIS
56
57 sleep(10,MICROSECONDS)
58  
59 sleep(3,MILLISECONDS)
60  
61 sleep(1,SECOND)
62 sleep(2,SECONDS)
63  
64 sleep(5,MINUTES)
65  
66 sleep(1,HOURS)
67  
68 =head1 SEE ALSO
69  
70 L<Catmandu::Fix>
71  
72 =cut
« blib/lib/Catmandu/Iterable.pm ↑ Summary blib/lib/Catmandu/Cmd.pm »