line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model-Itself |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2007-2017 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Config::Model::Itself::BackendDetector ; |
11
|
|
|
|
|
|
|
$Config::Model::Itself::BackendDetector::VERSION = '2.013'; |
12
|
|
|
|
|
|
|
# since this package is mostly targeted for dev environments |
13
|
|
|
|
|
|
|
# let the detector detect models under development |
14
|
5
|
|
|
5
|
|
1666910
|
use lib 'lib'; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
34
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
542
|
use Pod::POM ; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
262
|
|
17
|
5
|
|
|
5
|
|
32
|
use File::Find ; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
263
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
29
|
use base qw/Config::Model::Value/ ; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
848
|
|
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
60951
|
use strict ; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
118
|
|
22
|
5
|
|
|
5
|
|
25
|
use warnings ; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
2578
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub setup_enum_choice { |
25
|
68
|
|
|
68
|
0
|
2242
|
my $self = shift ; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# using a hash to make sure that a backend is not listed twice. This may |
28
|
|
|
|
|
|
|
# happen in development environment where a backend in found in /usr/lib |
29
|
|
|
|
|
|
|
# and in ./lib (or ./blib) |
30
|
68
|
50
|
|
|
|
332
|
my %choices = map { ($_ => 1);} ref $_[0] ? @{$_[0]} : @_ ; |
|
205
|
|
|
|
|
685
|
|
|
68
|
|
|
|
|
271
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# find available backends in all @INC directories |
33
|
|
|
|
|
|
|
my $wanted = sub { |
34
|
680
|
|
|
680
|
|
1262
|
my $n = $File::Find::name ; |
35
|
680
|
100
|
66
|
|
|
13533
|
if (-f $_ and $n =~ s/\.pm$// and $n !~ /Any$/) { |
|
|
|
100
|
|
|
|
|
36
|
544
|
|
|
|
|
1853
|
$n =~ s!.*Backend/!! ; |
37
|
544
|
|
|
|
|
978
|
$n =~ s!/!::!g ; |
38
|
544
|
|
|
|
|
3264
|
$choices{$n} = 1 ; |
39
|
|
|
|
|
|
|
} |
40
|
68
|
|
|
|
|
512
|
} ; |
41
|
|
|
|
|
|
|
|
42
|
68
|
|
|
|
|
243
|
foreach my $inc (@INC) { |
43
|
769
|
|
|
|
|
1711
|
my $path = "$inc/Config/Model/Backend" ; |
44
|
769
|
100
|
|
|
|
10465
|
find ($wanted, $path ) if -d $path; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
68
|
|
|
|
|
992
|
$self->SUPER::setup_enum_choice(sort keys %choices) ; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set_help { |
51
|
68
|
|
|
68
|
0
|
76054943
|
my ($self,$args) = @_ ; |
52
|
|
|
|
|
|
|
|
53
|
68
|
|
50
|
|
|
371
|
my $help = delete $args->{help} || {} ; |
54
|
|
|
|
|
|
|
|
55
|
68
|
|
|
|
|
252
|
my $path = $INC{"Config/Model.pm"} ; |
56
|
68
|
|
|
|
|
431
|
$path =~ s!\.pm!/Backend! ; |
57
|
|
|
|
|
|
|
|
58
|
68
|
|
|
|
|
679
|
my $parser = Pod::POM->new(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $wanted = sub { |
61
|
680
|
|
|
680
|
|
1209831
|
my $n = $File::Find::name ; |
62
|
|
|
|
|
|
|
|
63
|
680
|
100
|
100
|
|
|
26722
|
return unless (-f $n and $n !~ /Any\.pm$/) ; |
64
|
544
|
|
|
|
|
1338
|
my $file = $n ; |
65
|
544
|
|
|
|
|
2566
|
$n =~ s/\.pm$//; |
66
|
544
|
|
|
|
|
3032
|
$n =~ s!/!::!g ; |
67
|
544
|
|
|
|
|
1191
|
my $perl_name = $n ; |
68
|
544
|
|
|
|
|
2303
|
$n =~ s!.*Backend::!! ; |
69
|
544
|
|
|
|
|
2220
|
$perl_name =~ s!.*Config!Config! ; |
70
|
|
|
|
|
|
|
|
71
|
544
|
|
50
|
|
|
2374
|
my $pom = $parser->parse_file($file)|| die $parser->error(); |
72
|
|
|
|
|
|
|
|
73
|
544
|
|
|
|
|
5061688
|
foreach my $head1 ($pom->head1()) { |
74
|
544
|
50
|
|
|
|
11235
|
if ($head1->title() eq 'NAME') { |
75
|
544
|
|
|
|
|
36966
|
my $c = $head1->content(); |
76
|
544
|
|
|
|
|
8022
|
$c =~ s/.*?-\s*//; |
77
|
544
|
|
|
|
|
71208
|
$c =~ s/\n//g; |
78
|
544
|
|
|
|
|
2844
|
$help->{$n} = $c . " provided by L<$perl_name>"; |
79
|
544
|
|
|
|
|
3184
|
last; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
68
|
|
|
|
|
1410
|
}; |
83
|
|
|
|
|
|
|
|
84
|
68
|
|
|
|
|
7232
|
find ($wanted, $path ) ; |
85
|
|
|
|
|
|
|
|
86
|
68
|
|
|
|
|
165295
|
$self->{help} = $help; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# ABSTRACT: Detect available read/write backends usable by config models |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |