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 1 1 100.0
total 19 19 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;
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 if ( $v->is_trial ) { # If the second part is odd.
41             #pod ...
42             #pod };
43             #pod
44             #pod # Other methods are inherited from Version::Dotted.
45             #pod
46             #pod =head1 DESCRIPTION
47             #pod
48             #pod This is subclass of C. Two features distinct it from the parent:
49             #pod
50             #pod =over
51             #pod
52             #pod =item *
53             #pod
54             #pod Version object always has at least 3 parts.
55             #pod
56             #pod $v = qv( v1 ); # v1.0.0
57             #pod $v->part( 0 ) == 1; # Parts 0, 1, 2 are always defined.
58             #pod $v->part( 1 ) == 0; # Zero if not specified explicitly.
59             #pod $v->part( 2 ) == 0; # ditto
60             #pod $v->part( 3 ) == undef; # But may be defined.
61             #pod
62             #pod =item *
63             #pod
64             #pod The second part defines the release status: odd numbers denotes a trial release.
65             #pod
66             #pod $v = qv( v1.0 ); # $v == v1.0.0
67             #pod $v->is_trial; # false
68             #pod $v->bump( 1 ); # $v == v1.1.0
69             #pod $v->is_trial; # true
70             #pod
71             #pod =back
72             #pod
73             #pod Such versioning scheme was used by Linux kernel (between 1.0 and 2.6) and still used by Perl.
74             #pod
75             #pod =cut
76              
77             package Version::Dotted::Odd;
78              
79 2     2   33517 use strict;
  2         3  
  2         59  
80 2     2   6 use warnings;
  2         3  
  2         66  
81              
82             # ABSTRACT: Use odd/even versioning scheme in your Perl modules
83             our $VERSION = 'v0.0.0_06'; # TRIAL VERSION
84              
85 2     2   366 use parent 'Version::Dotted';
  2         221  
  2         7  
86              
87 9     9   13 sub _min_len { 3 }; ## no critic ( ProhibitUnusedPrivateSubroutines, RequireFinalReturn )
88              
89             # --------------------------------------------------------------------------------------------------
90              
91             #pod =method is_trial
92             #pod
93             #pod Returns true if the second version part is an odd number, and false otherwise.
94             #pod
95             #pod =cut
96              
97             sub is_trial {
98 6     6 1 21 my ( $self ) = @_;
99 6         6 my $v = $self->{ version };
100 6         20 return $v->[ 1 ] % 2 != 0;
101             };
102              
103             # --------------------------------------------------------------------------------------------------
104              
105             1;
106              
107             # --------------------------------------------------------------------------------------------------
108              
109             #pod =head1 SEE ALSO
110             #pod
111             #pod =for :list
112             #pod = L
113             #pod
114             #pod =head1 COPYRIGHT AND LICENSE
115             #pod
116             #pod Copyright (C) 2016 Van de Bugger
117             #pod
118             #pod License GPLv3+: The GNU General Public License version 3 or later
119             #pod .
120             #pod
121             #pod This is free software: you are free to change and redistribute it. There is
122             #pod NO WARRANTY, to the extent permitted by law.
123             #pod
124             #pod
125             #pod =cut
126              
127             # ------------------------------------------------------------------------------------------------
128             #
129             # file: doc/what.pod
130             #
131             # This file is part of perl-Version-Dotted.
132             #
133             # ------------------------------------------------------------------------------------------------
134              
135             #pod =encoding UTF-8
136             #pod
137             #pod =head1 WHAT?
138             #pod
139             #pod C and its subclasses complement standard C class with version
140             #pod modification operations, which can be useful in distribution release tools.
141             #pod
142             #pod =cut
143              
144             # end of file #
145              
146              
147             # end of file #
148              
149             __END__