| 1 | package Java::Release::Obj; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use List::MoreUtils qw(none); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use Mo qw(default coerce is required); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 14 | our $VERSION = 0.04; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # Computer architecture | ||||||||||||||||||||||||||||
| 13 | 14 | has arch => ( | |||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||
| 15 | required => 1, | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Interim version. | ||||||||||||||||||||||||||||
| 19 | 14 | has interim => ( | |||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Operating system. | ||||||||||||||||||||||||||||
| 24 | 14 | has os => ( | |||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||
| 26 | required => 1, | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # Patch version. | ||||||||||||||||||||||||||||
| 30 | 14 | has patch => ( | |||||||||||||||||||||||||||
| 31 | is => 'ro', | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Release version. | ||||||||||||||||||||||||||||
| 35 | 14 | has release => ( | |||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||
| 37 | required => 1, | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # Update version. | ||||||||||||||||||||||||||||
| 41 | 14 | has update => ( | |||||||||||||||||||||||||||
| 42 | is => 'ro', | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # Version. | ||||||||||||||||||||||||||||
| 46 | sub version { | ||||||||||||||||||||||||||||
| 47 | 20 | ▶ | my ($self, $type) = @_; | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 20 | ▶ | if ($type && none { $type eq $_ } qw(old new)) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$type and &none(sub {
MC/DC100%2/2
$type and &none(sub {
$type eq $_;
}
, "old", "new")
$type
&none(sub {
$type eq $_;
}
, "old", "new")
Truth table100%3/3
A and B
A= $typeB= &none(sub {
$type eq $_;
}
, "old", "new")
| |||||||||||||||||||||||||||||
| 50 | 1 | err "Bad version type. Possible values are 'new' or 'old'.", | |||||||||||||||||||||||||||
| 51 | 'type', $type; | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 19 | ▶ | $type //= 'new'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$type //= "new"
MC/DC100%1/1
$type //= "new"
$type
Truth table100%2/2
A
A= $type
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 19 | my $version = $self->release; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # Version like 'release'.'interim'.'update'.'patch' | ||||||||||||||||||||||||||||
| 58 | 19 | ▶ | if ($type eq 'new') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 12 | ▶ | if ($self->update) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 9 | ▶ | if ($self->interim) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 4 | $version .= '.'.$self->interim; | |||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||
| 63 | 5 | $version .= '.0'; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 9 | $version .= '.'.$self->update; | |||||||||||||||||||||||||||
| 66 | 9 | ▶ | if ($self->patch) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 1 | $version .= '.'.$self->patch; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # Version like 'release'u'update' | ||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||
| 73 | 7 | ▶ | if ($self->interim || $self->patch) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->interim or $self->patch
MC/DC100%2/2
$self->interim or $self->patch
$self->interim
$self->patch
Truth table100%3/3
A or B
A= $self->interimB= $self->patch
| |||||||||||||||||||||||||||||
| 74 | 2 | err 'Cannot create old version of version with '. | |||||||||||||||||||||||||||
| 75 | 'interim or patch value.'; | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 5 | ▶ | if ($self->update) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 4 | $version .= 'u'.$self->update; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 17 | return $version; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # Version name. | ||||||||||||||||||||||||||||
| 86 | sub version_name { | ||||||||||||||||||||||||||||
| 87 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
version_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 10 | my $version_name = 'Java '.$self->release; | |||||||||||||||||||||||||||
| 90 | 10 | ▶ | if ($self->interim) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 3 | $version_name .= ' Major '.$self->interim; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 10 | ▶ | if ($self->update) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 7 | $version_name .= ' Update '.$self->update; | |||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||
| 96 | 3 | $version_name .= ' GA'; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 10 | return $version_name; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 14 | 1; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | __END__ | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =pod | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =encoding utf8 | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 NAME | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Java::Release::Obj - Data object for Java::Release. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | use Java::Release::Obj; | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | my $obj = Java::Release::Obj->new(%params); | ||||||||||||||||||||||||||||
| 119 | my $arch = $obj->arch | ||||||||||||||||||||||||||||
| 120 | my $interim = $obj->interim; | ||||||||||||||||||||||||||||
| 121 | my $os = $obj->os; | ||||||||||||||||||||||||||||
| 122 | my $patch = $obj->patch; | ||||||||||||||||||||||||||||
| 123 | my $release = $obj->release; | ||||||||||||||||||||||||||||
| 124 | my $update = $obj->update; | ||||||||||||||||||||||||||||
| 125 | my $version = $obj->version($type); | ||||||||||||||||||||||||||||
| 126 | my $version_name = $obj->version_name; | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =head1 METHODS | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head2 C<constructor> | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | my $obj = Java::Release::Obj->new(%params); | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | Constructor. | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Returns instance of object. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =over 8 | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =item * C<arch> | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | Architecture. | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Parameter is required. | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =item * C<interim> | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | Interim version number. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | Parameter is optional. | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | Default values is undef. | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =item * C<os> | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Operating system. | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | Parameter is required. | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =item * C<patch> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | Patch version number. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | Parameter is optional. | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | Default values is undef. | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =item * C<release> | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | Release version number. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Parameter is required. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =item * C<update> | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | Update version number. | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | Parameter is optional. | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | Default values is undef. | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | =back | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =head2 C<arch> | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | my $arch = $obj->arch | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | Get architecture. | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | Returns string. | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head2 C<interim> | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | my $interim = $obj->interim; | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | Get interim version number. | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | Returns integer. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =head2 C<os> | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | my $os = $obj->os; | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | Get operating system. | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | Returns string. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head2 C<patch> | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | my $patch = $obj->patch; | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | Get patch version number. | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | Returns integer. | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head2 C<release> | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | my $release = $obj->release; | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | Get release version number. | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | Returns integer. | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =head2 C<update> | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | my $update = $obj->update; | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | Get update version number. | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | Returns integer. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =head2 C<version> | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | my $version = $obj->version($type); | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | Get version of release in short notation. There are two possibilities for C<$type>: 'new' (12.0.3) and 'old' (12u3) | ||||||||||||||||||||||||||||
| 237 | string. | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | Returns string. | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | =head2 C<version_name> | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | my $version_name = $obj->version_name; | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Get version of release in character notation. There are two possibilities to write: new and old | ||||||||||||||||||||||||||||
| 246 | version. | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | Returns string. | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | =head1 ERRORS | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | version(): | ||||||||||||||||||||||||||||
| 253 | Bad version type. Possible values are 'new' or 'old'. | ||||||||||||||||||||||||||||
| 254 | type: %s | ||||||||||||||||||||||||||||
| 255 | Cannot create old version of version with interim or patch value. | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =head1 EXAMPLE | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | use strict; | ||||||||||||||||||||||||||||
| 260 | use warnings; | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | use Data::Printer; | ||||||||||||||||||||||||||||
| 263 | use Java::Release::Obj; | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | my $obj = Java::Release::Obj->new( | ||||||||||||||||||||||||||||
| 266 | arch => 'i386', | ||||||||||||||||||||||||||||
| 267 | os => 'linux', | ||||||||||||||||||||||||||||
| 268 | release => 1, | ||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | p $obj; | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | # Output like: | ||||||||||||||||||||||||||||
| 274 | # Java::Release::Obj { | ||||||||||||||||||||||||||||
| 275 | # Parents Mo::Object | ||||||||||||||||||||||||||||
| 276 | # public methods (0) | ||||||||||||||||||||||||||||
| 277 | # private methods (0) | ||||||||||||||||||||||||||||
| 278 | # internals: { | ||||||||||||||||||||||||||||
| 279 | # arch "i386", | ||||||||||||||||||||||||||||
| 280 | # os "linux", | ||||||||||||||||||||||||||||
| 281 | # release 1 | ||||||||||||||||||||||||||||
| 282 | # } | ||||||||||||||||||||||||||||
| 283 | # } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | L<Error::Pure>, | ||||||||||||||||||||||||||||
| 288 | L<List::MoreUtils>, | ||||||||||||||||||||||||||||
| 289 | L<Mo>. | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =head1 REPOSITORY | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | L<https://github.com/michal-josef-spacek/Java-Release> | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | Michal Josef Špaček L<mailto:skim@cpan.org> | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | L<http://skim.cz> | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | © 2020-2021 Michal Josef Špaček | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | BSD 2-Clause License | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =head1 VERSION | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0.04 | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | =cut | ||||||||||||||||||||||||||||