File Coverage

blib/lib/Date/Lectionary/Year.pm
Criterion Covered Total %
statement 40 42 95.2
branch 5 6 83.3
condition n/a
subroutine 14 15 93.3
pod 1 1 100.0
total 60 64 93.7


line stmt bran cond sub pod time code
1             package Date::Lectionary::Year;
2              
3 10     10   172 use v5.22;
  10         40  
4 10     10   72 use strict;
  10         29  
  10         256  
5 10     10   50 use warnings;
  10         30  
  10         350  
6              
7 10     10   68 use Moose;
  10         25  
  10         69  
8 10     10   68355 use MooseX::StrictConstructor;
  10         24  
  10         94  
9 10     10   32218 use Carp;
  10         24  
  10         859  
10 10     10   80 use Try::Catch;
  10         25  
  10         636  
11 10     10   71 use namespace::autoclean;
  10         169  
  10         112  
12 10     10   981 use Moose::Util::TypeConstraints;
  10         21  
  10         109  
13              
14             =head1 NAME
15              
16             Date::Lectionary::Year - Cycle Year for the Lectionary
17              
18             =head1 VERSION
19              
20             Version 1.20200203
21              
22             =cut
23              
24 10     10   23543 use version; our $VERSION = version->declare("v1.20200203");
  10         26  
  10         85  
25              
26             =head1 SYNOPSIS
27              
28             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.
29              
30             =cut
31              
32             enum 'litCycleYear', [qw(A B C)];
33 10     10   1310 no Moose::Util::TypeConstraints;
  10         135  
  10         77  
34              
35             =head1 SUBROUTINES/METHODS
36              
37             =cut
38              
39             has 'year' => (
40             is => 'ro',
41             isa => 'Int',
42             required => 1,
43             );
44              
45             has 'name' => (
46             is => 'ro',
47             isa => 'litCycleYear',
48             writer => '_setName',
49             init_arg => undef,
50             );
51              
52             =head2 BUILD
53              
54             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.
55              
56             =cut
57              
58             sub BUILD {
59 615     615 1 1093 my $self = shift;
60              
61 615         17229 $self->_setName( _determineYear( $self->year ) );
62             }
63              
64             =head2 _determineYear
65              
66             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.
67              
68             =cut
69              
70             sub _determineYear {
71 615     615   1093 my $calYear = shift;
72              
73             try {
74 615 100   615   14409 if ( $calYear % 3 == 0 ) {
    100          
    50          
75 218         578 return 'A';
76             }
77             elsif ( ( $calYear - 1 ) % 3 == 0 ) {
78 188         563 return 'B';
79             }
80             elsif ( ( $calYear - 2 ) % 3 == 0 ) {
81 209         550 return 'C';
82             }
83             else {
84 0           confess "The liturgical year for the year [" . $calYear . "] could not be determined.";
85             }
86             }
87             catch {
88 0     0     confess "A liturgical year for the value [" . $calYear . "] could not be calculated.";
89 615         3951 };
90             }
91              
92             =head1 AUTHOR
93              
94             Michael Wayne Arnold, C<< <michael at rnold.info> >>
95              
96             =head1 BUGS
97              
98             Please report any bugs or feature requests to C<bug-date-lectionary at rt.cpan.org>, or through
99             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Date-Lectionary-Year>. I will be notified, and then you'll
100             automatically be notified of progress on your bug as I make changes.
101              
102             =head1 SUPPORT
103              
104             You can find documentation for this module with the perldoc command.
105              
106             perldoc Date::Lectionary::Year
107              
108              
109             You can also look for information at:
110              
111             =over 4
112              
113             =item * RT: CPAN's request tracker (report bugs here)
114              
115             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Date-Lectionary-Year>
116              
117             =item * AnnoCPAN: Annotated CPAN documentation
118              
119             L<http://annocpan.org/dist/Date-Lectionary-Year>
120              
121             =item * CPAN Ratings
122              
123             L<http://cpanratings.perl.org/d/Date-Lectionary-Year>
124              
125             =item * Search CPAN
126              
127             L<http://search.cpan.org/dist/Date-Lectionary-Year/>
128              
129             =back
130              
131             =head1 ACKNOWLEDGEMENTS
132              
133             Many thanks to my beautiful wife, Jennifer, my amazing daughter, Rosemary, and my sweet son, Oliver. But, above all, SOLI DEO GLORIA!
134              
135             =head1 LICENSE
136              
137             Copyright 2016-2018 MICHAEL WAYNE ARNOLD
138              
139             Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
140              
141             1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
142              
143             2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
144              
145             THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146              
147              
148             =cut
149              
150             __PACKAGE__->meta->make_immutable;
151              
152             1; # End of Date::Lectionary::Year