File Coverage

blib/lib/Date/Lectionary/Year.pm
Criterion Covered Total %
statement 26 36 72.2
branch 0 6 0.0
condition n/a
subroutine 9 13 69.2
pod 1 1 100.0
total 36 56 64.2


line stmt bran cond sub pod time code
1             package Date::Lectionary::Year;
2              
3 1     1   2176 use v5.22;
  1         3  
4 1     1   5 use strict;
  1         1  
  1         19  
5 1     1   4 use warnings;
  1         2  
  1         25  
6              
7 1     1   5 use Moose;
  1         1  
  1         6  
8 1     1   5838 use Carp;
  1         3  
  1         75  
9 1     1   16 use Try::Tiny;
  1         3  
  1         62  
10 1     1   408 use namespace::autoclean;
  1         6429  
  1         16  
11 1     1   77 use Moose::Util::TypeConstraints;
  1         3  
  1         10  
12              
13             =head1 NAME
14              
15             Date::Lectionary::Year - Cycle Year for the Lectionary
16              
17             =head1 VERSION
18              
19             Version 1.20161227
20              
21             =cut
22              
23             our $VERSION = '1.20161227';
24              
25             =head1 SYNOPSIS
26              
27             A helper object for Date::Lectionary to package which keeps information about the liturgical cycle year for the RCL, ACNA, and possibly other three-year lectionary systems. Valid values for the liturgical cycle are A, B, or C.
28              
29             =cut
30              
31             enum 'litCycleYear', [qw(A B C)];
32 1     1   2277 no Moose::Util::TypeConstraints;
  1         2  
  1         4  
33              
34             =head1 SUBROUTINES/METHODS
35              
36             =cut
37              
38             has 'year' => (
39             is => 'ro',
40             isa => 'Int',
41             required => 1,
42             );
43              
44             has 'name' => (
45             is => 'ro',
46             isa => 'litCycleYear',
47             writer => '_setName',
48             init_arg => undef,
49             );
50              
51             =head2 BUILD
52              
53             Constructor for the Date::Lectionary::Year object. Takes a four-digit representation of the Common Era year and returns the correct liturgical cycle year for the RCL, ACNA, and possibly other three-year lectionary systems.
54              
55             =cut
56              
57             sub BUILD {
58 0     0 1   my $self = shift;
59              
60 0           $self->_setName( _determineYear( $self->year ) );
61             }
62              
63             =head2 _determineYear
64              
65             Private method that takes a four-digit representation of the Common Era year and calculates the liturgical year -- A, B, or C -- for the year.
66              
67             =cut
68              
69             sub _determineYear {
70 0     0     my $calYear = shift;
71              
72             try {
73 0 0   0     if ( $calYear % 3 == 0 ) {
    0          
    0          
74 0           return 'A';
75             }
76             elsif ( ( $calYear - 1 ) % 3 == 0 ) {
77 0           return 'B';
78             }
79             elsif ( ( $calYear - 2 ) % 3 == 0 ) {
80 0           return 'C';
81             }
82             else {
83 0           confess "The liturgical year for the year [" . $calYear
84             . "] could not be determined.";
85             }
86             }
87             catch {
88 0     0     confess "A liturgical year for the value [" . $calYear
89             . "] could not be calculated.";
90 0           };
91             }
92              
93             =head1 AUTHOR
94              
95             Michael Wayne Arnold, C<< <marmanold at cpan.org> >>
96              
97             =head1 BUGS
98              
99             Please report any bugs or feature requests to C<bug-date-lectionary at rt.cpan.org>, or through
100             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-Lectionary-Year>. I will be notified, and then you'll
101             automatically be notified of progress on your bug as I make changes.
102              
103             =head1 SUPPORT
104              
105             You can find documentation for this module with the perldoc command.
106              
107             perldoc Date::Lectionary::Year
108              
109              
110             You can also look for information at:
111              
112             =over 4
113              
114             =item * RT: CPAN's request tracker (report bugs here)
115              
116             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Lectionary-Year>
117              
118             =item * AnnoCPAN: Annotated CPAN documentation
119              
120             L<http://annocpan.org/dist/Date-Lectionary-Year>
121              
122             =item * CPAN Ratings
123              
124             L<http://cpanratings.perl.org/d/Date-Lectionary-Year>
125              
126             =item * Search CPAN
127              
128             L<http://search.cpan.org/dist/Date-Lectionary-Year/>
129              
130             =back
131              
132             =head1 ACKNOWLEDGEMENTS
133              
134             Many thanks to my beautiful wife, Jennifer, and my amazing daughter, Rosemary. But, above all, SOLI DEO GLORIA!
135              
136             =head1 LICENSE AND COPYRIGHT
137              
138             Copyright 2016 Michael Wayne Arnold.
139              
140             This program is free software; you can redistribute it and/or modify it
141             under the terms of either: the GNU General Public License as published
142             by the Free Software Foundation; or the Artistic License.
143              
144             See L<http://dev.perl.org/licenses/> for more information.
145              
146              
147             =cut
148              
149             __PACKAGE__->meta->make_immutable;
150              
151             1; # End of Date::Lectionary::Year