line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fukurama::Class::Version; |
2
|
|
|
|
|
|
|
our $VERSION = 0.02; |
3
|
12
|
|
|
12
|
|
29412
|
use Fukurama::Class::Rigid; |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
82
|
|
4
|
12
|
|
|
12
|
|
75
|
use Fukurama::Class::Carp; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
56
|
|
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 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# AUTOMAGIC void |
49
|
|
|
|
|
|
|
sub import { |
50
|
66
|
|
|
66
|
|
3988
|
my $class = $_[0]; |
51
|
66
|
|
|
|
|
94
|
my $version = $_[1]; |
52
|
|
|
|
|
|
|
|
53
|
66
|
|
|
|
|
324
|
my ($caller_class) = caller(0); |
54
|
66
|
|
|
|
|
246
|
$class->version($caller_class, $version, 1); |
55
|
64
|
|
|
|
|
1346
|
return undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
# boolean |
58
|
|
|
|
|
|
|
sub version { |
59
|
69
|
|
|
69
|
1
|
901
|
my $class = $_[0]; |
60
|
69
|
|
|
|
|
96
|
my $caller_class = $_[1]; |
61
|
69
|
|
|
|
|
96
|
my $version = $_[2]; |
62
|
69
|
|
100
|
|
|
312
|
my $import_depth = $_[3] || 0; |
63
|
|
|
|
|
|
|
|
64
|
69
|
100
|
|
|
|
1056
|
if(!defined($version)) { |
|
|
100
|
|
|
|
|
|
65
|
1
|
|
|
|
|
5
|
_croak("Try to set undefined version to class '$caller_class'", $import_depth); |
66
|
|
|
|
|
|
|
} elsif($version !~ /^[0-9]+(?:[\._]?[0-9]+)*$/) { |
67
|
1
|
|
|
|
|
8
|
_croak("Try to set non-decimal version '$version' to class '$caller_class'", $import_depth); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
12
|
|
|
12
|
|
70
|
no strict 'refs'; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
1139
|
|
71
|
|
|
|
|
|
|
|
72
|
67
|
|
|
|
|
95
|
${"$caller_class\::VERSION"} = $version; |
|
67
|
|
|
|
|
363
|
|
73
|
67
|
|
|
|
|
150
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
1; |