lib/EWS/Calendar/Viewer/Controller/Calendar.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 69 CC 3 SCAR 11.5
CC
3
Cov
0%
get_year
6.0
get_month
6.0
BEGIN
2.0
CRAP 3.1
1 package EWS::Calendar::Viewer::Controller::Calendar;
2 BEGIN {
3 $EWS::Calendar::Viewer::Controller::Calendar::VERSION = '1.111982';
4 }
5  
6 use strict;
7 use warnings FATAL => 'all';
8  
9 use base qw( Catalyst::Controller );
10  
11 use DateTime;
12 use Calendar::Simple ();
13  
14 __PACKAGE__->config->{namespace} = 'calendar';
15  
16 sub index : Chained('/base') PathPart('') Args(0) {
17 my ( $self, $c ) = @_;
18  
19 $c->stash->{calendar} = Calendar::Simple::calendar(
20 $c->stash->{now}->month,
21 $c->stash->{now}->year,
22 $c->config->{start_of_week},
23 );
24  
25 $c->forward('retrieve');
26 $c->stash->{template} = 'month.tt';
27 }
28  
29 sub get_year : Chained('/base') PathPart('') CaptureArgs(1) {
30 my ( $self, $c, $year ) = @_;
31  
32 $c->detach('index') unless $year =~ /^\d{4}$/;
33
34 $c->stash->{now}->set( year => $year );
35 }
36  
37 sub custom_year : Chained('get_year') PathPart('') Args(0) {
38 my ($self, $c) = @_;
39 $c->forward('index');
40 }
41  
42 sub get_month : Chained('get_year') PathPart('') CaptureArgs(1) {
43 my ( $self, $c, $month ) = @_;
44  
45 $c->detach('index')
46 unless $month =~ /^\d{2}$/ and (($month >= 1) and ($month <= 12));
47
48 $c->stash->{now}->set( month => $month );
49 }
50  
51 sub custom_month : Chained('get_month') PathPart('') Args(0) {
52 my ($self, $c) = @_;
53 $c->forward('index');
54 }
55  
56 sub retrieve : Private {
57 my ($self, $c) = @_;
58  
59 $c->stash->{entries} = $c->model('EWSClient')->calendar->retrieve({
60 start => $c->stash->{now},
61 end => $c->stash->{now}->clone->add( months => 1 ),
62 })->items;
63  
64 $c->stash->{retrieved} = DateTime->now();
65 }
66  
67 1;