Lectionary/Year.pm

filter: Statementstmt 95.8% 46 / 48 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 93.3% 14 / 15 Podpod 100% 1 / 1 totaltotal 94.2% 66 / 70 CC 4 SCAR 5.6
CC
4
Cov
94%
__ANON__
4.1
__ANON__
2.0
_determineYear
1.0
CRAP 1.7
« Lectionary/Day.pm ↑ Summary Lectionary.pm »
1 package Date::Lectionary::Year;
2  
3 10 ▶use v5.22;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Try::Catch;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶use version; our $VERSION = version->declare("v1.20200203");
Subroutine BEGIN: called CC=1 SCAR=0.0
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 10 enum 'litCycleYear', [qw(A B C)];
33 10 ▶no Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 =head1 SUBROUTINES/METHODS
36  
37 =cut
38  
39 10 has 'year' => (
40 is => 'ro',
41 isa => 'Int',
42 required => 1,
43 );
44  
45 10 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 615 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod documented
59 615 my $self = shift;
60  
61 615 $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 615 ▶sub _determineYear {
Subroutine _determineYear: called CC=1 SCAR=0.1
71 615 my $calYear = shift;
72  
73 615 ▶ try {
Subroutine __ANON__: called CC=4 SCAR=14.1
74 615 ▶ if ( $calYear % 3 == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($calYear % 3 == 0) { } 218 397 615
elsif (($calYear - 1) % 3 == 0) { } 188 209 397
elsif (($calYear - 2) % 3 == 0) { } 209 0 209
75 218 return 'A';
76 }
77 elsif ( ( $calYear - 1 ) % 3 == 0 ) {
78 188 return 'B';
79 }
80 elsif ( ( $calYear - 2 ) % 3 == 0 ) {
81 209 return 'C';
82 }
83 else {
84 0 confess "The liturgical year for the year [" . $calYear . "] could not be determined.";
85 }
86 }
87 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 0 confess "A liturgical year for the value [" . $calYear . "] could not be calculated.";
89 615 };
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 10 __PACKAGE__->meta->make_immutable;
151  
152 10 1; # End of Date::Lectionary::Year
« Lectionary/Day.pm ↑ Summary Lectionary.pm »