line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
94786
|
use 5.008001; |
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
331
|
|
2
|
8
|
|
|
8
|
|
40
|
use strict; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
249
|
|
3
|
8
|
|
|
8
|
|
40
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
616
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package superclass; |
6
|
|
|
|
|
|
|
# ABSTRACT: Like parent, but with version checks |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
6803
|
use version 0.9901; # sane UNIVERSAL::VERSION, more or less |
|
8
|
|
|
|
|
19555
|
|
|
8
|
|
|
|
|
60
|
|
10
|
8
|
|
|
8
|
|
7835
|
use Module::Load 0.24 (); # apostrophe support |
|
8
|
|
|
|
|
9959
|
|
|
8
|
|
|
|
|
1516
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# module name regular expression |
13
|
|
|
|
|
|
|
my $mod_re = qr/^[A-Z_a-z][0-9A-Z_a-z]*(?:(?:::|')[0-9A-Z_a-z]+)*$/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
29
|
|
|
29
|
|
17443
|
my $class = shift; |
17
|
|
|
|
|
|
|
|
18
|
29
|
|
|
|
|
69
|
my $inheritor = caller(0); |
19
|
|
|
|
|
|
|
|
20
|
29
|
|
|
|
|
44
|
my $no_require; |
21
|
29
|
100
|
66
|
|
|
212
|
if ( @_ and $_[0] eq '-norequire' ) { |
22
|
8
|
|
|
|
|
12
|
shift @_; |
23
|
8
|
|
|
|
|
19
|
$no_require++; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
29
|
|
|
|
|
122
|
while (@_) { |
27
|
31
|
|
|
|
|
52
|
my $module = shift @_; |
28
|
31
|
100
|
100
|
|
|
232
|
my $version = ( @_ && $_[0] !~ $mod_re ) ? shift(@_) : 0; |
29
|
31
|
100
|
|
|
|
79
|
if ( $module eq $inheritor ) { |
30
|
1
|
|
|
|
|
11
|
warn "Class '$inheritor' tried to inherit from itself\n"; |
31
|
|
|
|
|
|
|
} |
32
|
31
|
100
|
|
|
|
125
|
Module::Load::load($module) unless $no_require; # dies if not found |
33
|
27
|
100
|
|
|
|
4761
|
$module->VERSION($version) if $version; # don't check '0' |
34
|
|
|
|
|
|
|
{ |
35
|
8
|
|
|
8
|
|
54
|
no strict 'refs'; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
998
|
|
|
20
|
|
|
|
|
46
|
|
36
|
20
|
|
|
|
|
23
|
push @{"$inheritor\::ISA"}, $module; |
|
20
|
|
|
|
|
6928
|
|
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
superclass - Like parent, but with version checks |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.003 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package Baz; |
58
|
|
|
|
|
|
|
use superclass qw(Foo Bar), 'Baz' => 1.23; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Allows you to both load one or more modules, while setting up inheritance from |
63
|
|
|
|
|
|
|
those modules at the same time. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
If a module in the import list is followed by something that doesn't look like |
66
|
|
|
|
|
|
|
a legal module name, the C method will be called with it as an argument; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The synopsis example is mostly similar in effect to |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
package Baz; |
71
|
|
|
|
|
|
|
BEGIN { |
72
|
|
|
|
|
|
|
require Foo; |
73
|
|
|
|
|
|
|
require Bar; |
74
|
|
|
|
|
|
|
require Baz; |
75
|
|
|
|
|
|
|
Baz->VERSION(1.23) |
76
|
|
|
|
|
|
|
push @ISA, qw(Foo Bar Baz); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Dotted-decimal versions should be given as a string, not a raw v-string, and |
80
|
|
|
|
|
|
|
must include at least one decimal point. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
use superclass 'Bar' => v65.65.65; # BAD: loads AAA.pm |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
use superclass 'Bar' => 'v6'; # BAD: loads v6.pm |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
use superclass 'Foo' => 'v0.10.0'; # OK |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
If the first import argument is C<-norequire>, no files will be loaded |
89
|
|
|
|
|
|
|
(but any versions given will still be checked). |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is helpful for the case where a package lives within the current file |
92
|
|
|
|
|
|
|
or a differently named file: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package MyHash; |
95
|
|
|
|
|
|
|
use Tie::Hash; |
96
|
|
|
|
|
|
|
use superclass -norequire, 'Tie::StdHash'; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=for Pod::Coverage method_names_here |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item Class 'Foo' tried to inherit from itself |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Attempting to inherit from yourself generates a warning. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
package Foo; |
109
|
|
|
|
|
|
|
use superclass 'Foo'; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 HISTORY |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This module was forked from L to add version checks. |
116
|
|
|
|
|
|
|
The L module was forked from L to remove the cruft |
117
|
|
|
|
|
|
|
that had accumulated in it. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Authors of or contributors to predecessor modules include Rafaƫl Garcia-Suarez, |
120
|
|
|
|
|
|
|
Bart Lateur, Max Maischein, Anno Siegel, and Michael Schwern |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SUPPORT |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Please report any bugs or feature requests through the issue tracker |
129
|
|
|
|
|
|
|
at L. |
130
|
|
|
|
|
|
|
You will be notified automatically of any progress on your issue. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 Source Code |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This is open source software. The code repository is available for |
135
|
|
|
|
|
|
|
public review and contribution under the terms of the license. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
git clone https://github.com/dagolden/superclass.git |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHOR |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
David Golden |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This software is copyright (c) 2013 by David Golden. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
150
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |