end_day.pm

filter: Statementstmt 96.0% 48 / 50 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 14 / 16 Podpod 0.0% 0 / 1 totaltotal 91.3% 63 / 69 CC 2 SCAR 2.1
CC
2
Cov
94%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.2
« start_day.pm ↑ Summary start_year.pm »
1 package Catmandu::Fix::end_day;
2 2 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Catmandu::Util qw(:is :check :array);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use DateTime::Format::Strptime;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use DateTime::TimeZone;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = "0.0132";
10  
11 2 with 'Catmandu::Fix::Base';
12  
13 2 has path => (
14 is => 'ro' ,
15 required => 1
16 );
17 has add => (
18 is => 'ro',
19 2 ▶ isa => sub { check_integer($_[0]); },
Subroutine __ANON__: called CC=1 SCAR=0.0
20 required => 0,
21 lazy => 1,
22 1 ▶ default => sub { 0; }
Subroutine __ANON__: called CC=1 SCAR=0.0
23 2 );
24 has time_zone => (
25 is => 'ro',
26 required => 1,
27 2 ▶ isa => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 2 check_string($_[0]);
29 },
30 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 "UTC"
32 }
33 2 );
34 has pattern => (
35 is => 'ro',
36 required => 1,
37 2 ▶ isa => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
38 2 check_string($_[0]);
39 },
40 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 "%FT%T.%NZ"
42 }
43 2 );
44  
45 2 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
46 2 my($orig,$class,$path,%args) = @_;
47  
48 2 $orig->($class,
49 path => $path,
50 %args
51 );
52  
53 2 };
54  
55 2 ▶sub emit {
Subroutine emit: called CC=1 SCAR=0.0
Pod undocumented
56 2 my($self,$fixer) = @_;
57  
58 2 my $path = $fixer->split_path($self->path());
59 2 ▶ my $end_day = $fixer->capture(sub{
Subroutine __ANON__: called CC=2 SCAR=7.0
60 2 my $skip = shift;
61 2 my $d = DateTime->now->set_time_zone($self->time_zone)->truncate(to => "day");
62 2 ▶ if(is_integer($skip)){
Branch: 1 branch
BranchTrueFalseTotal
if (is_integer($skip)) 2 0 2
63 2 $d->add(days => $skip);
64 }
65 2 $d->add(days => 1,seconds => -1);
66 2 $d;
67 2 });
68  
69 2 ▶ $fixer->emit_create_path($fixer->var,$path,sub{
Subroutine __ANON__: called CC=1 SCAR=0.0
70  
71 2 my $var = shift;
72  
73 2 my $d = $fixer->generate_var();
74 2 my $p = $fixer->emit_declare_vars($d);
75 2 $p .= " $d = ${end_day}->(".$self->add().");";
76 2 $p .= " ${var} = DateTime::Format::Strptime::strftime('".$self->pattern()."',$d);";
77  
78 2 $p;
79  
80 2 });
81  
82 }
83  
84 2 1;
85 __END__
« start_day.pm ↑ Summary start_year.pm »