line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Any::Base; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
1942
|
use strict; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
396
|
|
4
|
14
|
|
|
14
|
|
98
|
use warnings; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
3499
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Config::Any::Base - Base class for loaders |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This is a base class for all loaders. It currently handles the specification |
13
|
|
|
|
|
|
|
of dependencies in order to ensure the subclass can load the config file |
14
|
|
|
|
|
|
|
format. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 is_supported( ) |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Allows us to determine if the file format can be loaded. The can be done via |
21
|
|
|
|
|
|
|
one of two subclass methods: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over 4 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item * C - returns an array of items that must all be present in order to work |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item * C - returns an array of items in which at least one must be present |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=back |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
You can specify a module version by passing an array reference in the return. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub requires_all_of { [ 'My::Module', '1.1' ], 'My::OtherModule' } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Lack of specifying these subs will assume you require no extra modules to function. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub is_supported { |
40
|
25
|
|
|
25
|
1
|
11588
|
my ( $class ) = shift; |
41
|
25
|
|
|
|
|
46
|
local $@; |
42
|
25
|
100
|
|
|
|
206
|
if ( $class->can( 'requires_all_of' ) ) { |
43
|
10
|
|
50
|
|
|
25
|
return eval { |
44
|
|
|
|
|
|
|
_require($_) for $class->requires_all_of; |
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
} || 0; |
47
|
|
|
|
|
|
|
} |
48
|
15
|
100
|
|
|
|
91
|
if ( $class->can( 'requires_any_of' ) ) { |
49
|
11
|
|
|
|
|
49
|
eval { _require( $_ ); 1 } and return 1 |
|
5
|
|
|
|
|
35
|
|
50
|
7
|
|
100
|
|
|
31
|
for $class->requires_any_of; |
51
|
2
|
|
|
|
|
12
|
return 0; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# requires nothing! |
55
|
8
|
|
|
|
|
37
|
return 1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _require { |
59
|
21
|
|
|
21
|
|
77
|
my ( $input ) = shift; |
60
|
21
|
100
|
|
|
|
78
|
my ( $module, $version ) = ( ref $input ? @$input : $input ); |
61
|
21
|
|
|
|
|
112
|
(my $file = "$module.pm") =~ s{::}{/}g; |
62
|
21
|
|
|
|
|
2539
|
require $file; |
63
|
5
|
50
|
|
|
|
16
|
$module->VERSION($version) if $version; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Brian Cassidy |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Copyright 2008-2009 by Brian Cassidy |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
75
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=back |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |