File Coverage

blib/lib/Version/Dotted/Odd.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 20 20 100.0


line stmt bran cond sub pod time code
1             # ---------------------------------------------------------------------- copyright and license ---
2             #
3             # file: lib/Version/Dotted/Odd.pm
4             #
5             # Copyright © 2016 Van de Bugger.
6             #
7             # This file is part of perl-Version-Dotted.
8             #
9             # perl-Version-Dotted is free software: you can redistribute it and/or modify it under the terms
10             # of the GNU General Public License as published by the Free Software Foundation, either version
11             # 3 of the License, or (at your option) any later version.
12             #
13             # perl-Version-Dotted is distributed in the hope that it will be useful, but WITHOUT ANY
14             # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15             # PURPOSE. See the GNU General Public License for more details.
16             #
17             # You should have received a copy of the GNU General Public License along with
18             # perl-Version-Dotted. If not, see .
19             #
20             # ---------------------------------------------------------------------- copyright and license ---
21              
22             #pod =for :this This is C module/class documentation. However, read
23             #pod C module/class documentation first, since it contains many relevant details.
24             #pod
25             #pod =for :those General topics like getting source, building, installing, bug reporting and some
26             #pod others are covered in the F.
27             #pod
28             #pod =for test_synopsis my ( $v, $bool );
29             #pod
30             #pod =head1 SYNOPSIS
31             #pod
32             #pod use Version::Dotted::Odd; # import nothing
33             #pod use Version::Dotted::Odd 'qv'; # import qv
34             #pod
35             #pod # Construct:
36             #pod $v = Version::Dotted::Odd->new( v1.0 ); # v1.0.0 (at least 3 parts)
37             #pod $v = qv( v1.0.2.5 ); # v1.0.2.5
38             #pod
39             #pod # Release status:
40             #pod $bool = $v->is_trial; # true if the second part is odd.
41             #pod
42             #pod # See Version::Dotted for other methods.
43             #pod
44             #pod =head1 DESCRIPTION
45             #pod
46             #pod This is subclass of C. Two features distinct it from the parent:
47             #pod
48             #pod =over
49             #pod
50             #pod =item *
51             #pod
52             #pod Version object always has at least 3 parts.
53             #pod
54             #pod $v = qv( v1 ); # v1.0.0
55             #pod $v->part( 0 ) == 1; # Parts 0, 1, 2 are always defined.
56             #pod $v->part( 1 ) == 0; # Zero if not specified explicitly.
57             #pod $v->part( 2 ) == 0; # ditto
58             #pod $v->part( 3 ) == undef; # But may be defined.
59             #pod
60             #pod =item *
61             #pod
62             #pod The second part defines the release status: odd number denotes a trial release.
63             #pod
64             #pod $v = qv( v1.0 ); # $v == v1.0.0
65             #pod $v->is_trial; # false
66             #pod $v->bump( 1 ); # $v == v1.1.0
67             #pod $v->is_trial; # true
68             #pod
69             #pod Such versioning scheme was used by Linux kernel (between 1.0 and 2.6) and still used by Perl.
70             #pod
71             #pod =back
72             #pod
73             #pod
74             #pod =cut
75              
76             package Version::Dotted::Odd;
77              
78 2     2   34074 use strict;
  2         3  
  2         44  
79 2     2   7 use warnings;
  2         2  
  2         66  
80              
81             # ABSTRACT: Odd/even versioning scheme
82             our $VERSION = 'v0.0.0_07'; # TRIAL VERSION
83              
84 2     2   376 use parent 'Version::Dotted';
  2         255  
  2         8  
85              
86             # --------------------------------------------------------------------------------------------------
87              
88             #pod =Attribute min_len
89             #pod
90             #pod Minimal number of parts, read-only.
91             #pod
92             #pod $int = Version::Dotted::Odd->min_len; # == 3
93             #pod
94             #pod C objects always have at least 3 parts.
95             #pod
96             #pod =cut
97              
98 13     13 1 15 sub min_len { 3 }; ## no critic ( RequireFinalReturn )
99              
100             # --------------------------------------------------------------------------------------------------
101              
102             #pod =method is_trial
103             #pod
104             #pod Returns true in case of trial version, and false otherwise.
105             #pod
106             #pod $bool = $v->is_trial;
107             #pod
108             #pod A version is considered trial if the second part is an odd number:
109             #pod
110             #pod qv( v1.1.3 )->is_trial; # true
111             #pod qv( v1.2.0 )->is_trial; # false
112             #pod
113             #pod =cut
114              
115             sub is_trial {
116 6     6 1 23 my ( $self ) = @_;
117 6         7 my $v = $self->{ version };
118 6         20 return $v->[ 1 ] % 2 != 0;
119             };
120              
121             # --------------------------------------------------------------------------------------------------
122              
123             1;
124              
125             # --------------------------------------------------------------------------------------------------
126              
127             #pod =head1 SEE ALSO
128             #pod
129             #pod =for :list
130             #pod = L
131             #pod = L
132             #pod
133             #pod =head1 COPYRIGHT AND LICENSE
134             #pod
135             #pod Copyright (C) 2016 Van de Bugger
136             #pod
137             #pod License GPLv3+: The GNU General Public License version 3 or later
138             #pod .
139             #pod
140             #pod This is free software: you are free to change and redistribute it. There is
141             #pod NO WARRANTY, to the extent permitted by law.
142             #pod
143             #pod
144             #pod =cut
145              
146             # ------------------------------------------------------------------------------------------------
147             #
148             # file: doc/what.pod
149             #
150             # This file is part of perl-Version-Dotted.
151             #
152             # ------------------------------------------------------------------------------------------------
153              
154             #pod =encoding UTF-8
155             #pod
156             #pod =head1 WHAT?
157             #pod
158             #pod C and its subclasses complement standard C class with bump operation and
159             #pod (re)define trial versions differently.
160             #pod
161             #pod =cut
162              
163             # end of file #
164              
165              
166             # end of file #
167              
168             __END__