Renderer/Util.pm

filter: Statementstmt 41.8% 18 / 43 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 35.9% 23 / 64 CC 7 SCAR 30.3
CC
7
Cov
33%
get_max_week_rows
42.0
round_number
6.0
BEGIN
1.0
CRAP 20.7
« Renderer/Text.pm ↑ Summary Renderer.pm »
1 package Calendar::Plugin::Renderer::Util;
2  
3 3 $Calendar::Plugin::Renderer::Util::VERSION = '0.13';
4 3 $Calendar::Plugin::Renderer::Util::AUTHORITY = 'cpan:MANWAR';
5  
6 =head1 NAME
7  
8 Calendar::Plugin::Renderer::Util - Helper package for Calendar::Plugin::Renderer.
9  
10 =head1 VERSION
11  
12 Version 0.13
13  
14 =cut
15  
16 3 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 our @EXPORT = qw(round_number get_max_week_rows);
18  
19 3 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =head1 DESCRIPTION
24  
25 B<FOR INTERNAL USE ONLY>.
26  
27 =head2 METHODS
28  
29 =head1 round_number($number, $digits)
30  
31 Round the given C<$number> by C<$digits>. By default round it by 4 digits.
32  
33 =cut
34  
35 sub round_number {
36 0 ▶ my ($number, $digits) = @_;
Subroutine round_number: not called CC=2 SCAR=17.9
Pod undocumented
37  
38 0 ▶ $digits = 4 unless defined $digits;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $digits 0 0 0
39 0 my $format = sprintf("%02d", $digits);
40 0 $format = '%.' . $format . 'f';
41  
42 0 return sprintf($format, $number);
43 }
44  
45 sub get_max_week_rows {
46 0 ▶ my ($start_index, $max_days, $max_week_row) = @_;
Subroutine get_max_week_rows: not called CC=6 SCAR=37.4
Pod undocumented
47  
48 0 my $rows = 1;
49 0 my $i = 1;
50 0 ▶ while ($i < $start_index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $start_index) 0 0 0
51 0 $i++;
52 }
53  
54 0 my $d = 1;
55 0 ▶ while ($i <= 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= 7) 0 0 0
56 0 $d++;
57 0 $i++;
58 }
59  
60 0 $rows++;
61 0 my $k = 1;
62 0 ▶ while ($d <= $max_days) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d <= $max_days) 0 0 0
63 0 ▶ if ($k == 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k == 7) { } 0 0 0
64 0 $rows++;
65 0 $k = 1;
66 }
67 else {
68 0 $k++;
69 }
70 0 $d++;
71 }
72  
73 0 ▶ if ($rows < $max_week_row) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rows < $max_week_row) { } 0 0 0
74 0 return $max_week_row;
75 }
76 else {
77 0 return $rows;
78 }
79 }
80  
81 =head1 AUTHOR
82  
83 Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>
84  
85 =head1 REPOSITORY
86  
87 L<https://github.com/manwar/Calendar-Plugin-Renderer>
88  
89 =head1 BUGS
90  
91 Please report any bugs / feature requests to C<bug-calendar-plugin-renderer at rt.cpan.org>,
92 or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Calendar-Plugin-Renderer>.
93 I will be notified, and then you'll automatically be notified of progress on your
94 bug as I make changes.
95  
96 =head1 SUPPORT
97  
98 You can find documentation for this module with the perldoc command.
99  
100 perldoc Calendar::Plugin::Renderer::Util
101  
102 You can also look for information at:
103  
104 =over 4
105  
106 =item * RT: CPAN's request tracker
107  
108 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Calendar-Plugin-Renderer>
109  
110 =item * AnnoCPAN: Annotated CPAN documentation
111  
112 L<http://annocpan.org/dist/Calendar-Plugin-Renderer>
113  
114 =item * CPAN Ratings
115  
116 L<http://cpanratings.perl.org/d/Calendar-Plugin-Renderer>
117  
118 =item * Search CPAN
119  
120 L<http://search.cpan.org/dist/Calendar-Plugin-Renderer/>
121  
122 =back
123  
124 =head1 LICENSE AND COPYRIGHT
125  
126 Copyright (C) 2015 - 2016 Mohammad S Anwar.
127  
128 This program is free software; you can redistribute it and / or modify it under
129 the terms of the the Artistic License (2.0). You may obtain a copy of the full
130 license at:
131  
132 L<http://www.perlfoundation.org/artistic_license_2_0>
133  
134 Any use, modification, and distribution of the Standard or Modified Versions is
135 governed by this Artistic License.By using, modifying or distributing the Package,
136 you accept this license. Do not use, modify, or distribute the Package, if you do
137 not accept this license.
138  
139 If your Modified Version has been derived from a Modified Version made by someone
140 other than you,you are nevertheless required to ensure that your Modified Version
141 complies with the requirements of this license.
142  
143 This license does not grant you the right to use any trademark, service mark,
144 tradename, or logo of the Copyright Holder.
145  
146 This license includes the non-exclusive, worldwide, free-of-charge patent license
147 to make, have made, use, offer to sell, sell, import and otherwise transfer the
148 Package with respect to any patent claims licensable by the Copyright Holder that
149 are necessarily infringed by the Package. If you institute patent litigation
150 (including a cross-claim or counterclaim) against any party alleging that the
151 Package constitutes direct or contributory patent infringement,then this Artistic
152 License to you shall terminate on the date that such litigation is filed.
153  
154 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
155 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
156 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
157 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
158 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
159 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
160 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
161  
162 =cut
163  
164 3 1; # End of Calendar::Plugin::Renderer::Util
« Renderer/Text.pm ↑ Summary Renderer.pm »