Class/Version.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 39 / 39 CC 4 SCAR 9.2
CC
4
Cov
100%
version
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
« Class/Attributes/OOStandard.pm ↑ Summary Class/Attributes/OOStandard/Decorator.pm »
1 package Fukurama::Class::Version;
2 11 our $VERSION = 0.02;
3 11 ▶use Fukurama::Class::Rigid;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Fukurama::Class::Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Fukurama::Class::Version - Pragma to set package-version
9  
10 =head1 VERSION
11  
12 Version 0.02 (beta)
13  
14 =head1 SYNOPSIS
15  
16 package MyClass;
17 use Fukurama::Class::Version('1.10');
18  
19 =head1 DESCRIPTION
20  
21 This pragma-like module provides a set method for package version. It check the correctness of version-value
22 at compiletime. Use Fukurama::Class instead, to get all the features for OO.
23  
24 =head1 CONFIG
25  
26 -
27  
28 =head1 EXPORT
29  
30 $YourClass::VERSION : this global variable would be set at compiletime.
31  
32 =head1 METHODS
33  
34 =over 4
35  
36 =item version( version:DECIMAL ) return:BOOLEAN
37  
38 Helper-method, which would executed by every pragma usage.
39  
40 =back
41  
42 =head1 AUTHOR, BUGS, SUPPORT, ACKNOWLEDGEMENTS, COPYRIGHT & LICENSE
43  
44 see perldoc of L<Fukurama::Class>
45  
46 =cut
47  
48 # AUTOMAGIC void
49 53 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
50 53 my $class = $_[0];
51 53 my $version = $_[1];
52
53 53 my ($caller_class) = caller(0);
54 53 $class->version($caller_class, $version, 1);
55 51 return undef;
56 }
57 # boolean
58 54 ▶sub version {
Subroutine version: called CC=4 SCAR=13.9
Pod documented
59 54 my $class = $_[0];
60 54 my $caller_class = $_[1];
61 54 my $version = $_[2];
62 54 ▶ my $import_depth = $_[3] || 0;
Condition100%2/2
$_[3] || 0
l!l
531
MC/DC100%1/1
$_[3] || 0
$_[3]
Truth table100%2/2
A
A= $_[3]
Aresult
11
00
63
64 54 ▶ if(!defined($version)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $version) { } 1 53 54
elsif (not $version =~ /^[0-9]+(?:[\._]?[0-9]+)*$/) { } 1 52 53
65 1 _croak("Try to set undefined version to class '$caller_class'", $import_depth);
66 } elsif($version !~ /^[0-9]+(?:[\._]?[0-9]+)*$/) {
67 1 _croak("Try to set non-decimal version '$version' to class '$caller_class'", $import_depth);
68 }
69
70 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
71
72 52 ${"$caller_class\::VERSION"} = $version;
73 52 return 1;
74 }
75 11 1;
« Class/Attributes/OOStandard.pm ↑ Summary Class/Attributes/OOStandard/Decorator.pm »