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.012'; |
12
|
|
|
|
|
|
|
# since this package is mostly targeted for dev environments |
13
|
|
|
|
|
|
|
# let the detector detect models under development |
14
|
5
|
|
|
5
|
|
2031043
|
use lib 'lib'; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
44
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
689
|
use Pod::POM ; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
316
|
|
17
|
5
|
|
|
5
|
|
34
|
use File::Find ; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
309
|
|
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
5
|
|
38
|
use base qw/Config::Model::Value/ ; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
1139
|
|
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
75402
|
use strict ; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
152
|
|
22
|
5
|
|
|
5
|
|
31
|
use warnings ; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
3068
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub setup_enum_choice { |
25
|
68
|
|
|
68
|
0
|
2323
|
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
|
|
|
|
321
|
my %choices = map { ($_ => 1);} ref $_[0] ? @{$_[0]} : @_ ; |
|
205
|
|
|
|
|
753
|
|
|
68
|
|
|
|
|
279
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# find available backends in all @INC directories |
33
|
|
|
|
|
|
|
my $wanted = sub { |
34
|
680
|
|
|
680
|
|
1499
|
my $n = $File::Find::name ; |
35
|
680
|
100
|
66
|
|
|
14193
|
if (-f $_ and $n =~ s/\.pm$// and $n !~ /Any$/) { |
|
|
|
100
|
|
|
|
|
36
|
544
|
|
|
|
|
2125
|
$n =~ s!.*Backend/!! ; |
37
|
544
|
|
|
|
|
1119
|
$n =~ s!/!::!g ; |
38
|
544
|
|
|
|
|
3890
|
$choices{$n} = 1 ; |
39
|
|
|
|
|
|
|
} |
40
|
68
|
|
|
|
|
425
|
} ; |
41
|
|
|
|
|
|
|
|
42
|
68
|
|
|
|
|
273
|
foreach my $inc (@INC) { |
43
|
769
|
|
|
|
|
1909
|
my $path = "$inc/Config/Model/Backend" ; |
44
|
769
|
100
|
|
|
|
10781
|
find ($wanted, $path ) if -d $path; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
68
|
|
|
|
|
886
|
$self->SUPER::setup_enum_choice(sort keys %choices) ; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set_help { |
51
|
68
|
|
|
68
|
0
|
85438191
|
my ($self,$args) = @_ ; |
52
|
|
|
|
|
|
|
|
53
|
68
|
|
50
|
|
|
385
|
my $help = delete $args->{help} || {} ; |
54
|
|
|
|
|
|
|
|
55
|
68
|
|
|
|
|
294
|
my $path = $INC{"Config/Model.pm"} ; |
56
|
68
|
|
|
|
|
442
|
$path =~ s!\.pm!/Backend! ; |
57
|
|
|
|
|
|
|
|
58
|
68
|
|
|
|
|
697
|
my $parser = Pod::POM->new(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $wanted = sub { |
61
|
680
|
|
|
680
|
|
1438674
|
my $n = $File::Find::name ; |
62
|
|
|
|
|
|
|
|
63
|
680
|
100
|
100
|
|
|
23141
|
return unless (-f $n and $n !~ /Any\.pm$/) ; |
64
|
544
|
|
|
|
|
1603
|
my $file = $n ; |
65
|
544
|
|
|
|
|
2865
|
$n =~ s/\.pm$//; |
66
|
544
|
|
|
|
|
3363
|
$n =~ s!/!::!g ; |
67
|
544
|
|
|
|
|
1413
|
my $perl_name = $n ; |
68
|
544
|
|
|
|
|
2635
|
$n =~ s!.*Backend::!! ; |
69
|
544
|
|
|
|
|
2469
|
$perl_name =~ s!.*Config!Config! ; |
70
|
|
|
|
|
|
|
|
71
|
544
|
|
50
|
|
|
2855
|
my $pom = $parser->parse_file($file)|| die $parser->error(); |
72
|
|
|
|
|
|
|
|
73
|
544
|
|
|
|
|
5936613
|
foreach my $head1 ($pom->head1()) { |
74
|
544
|
50
|
|
|
|
13030
|
if ($head1->title() eq 'NAME') { |
75
|
544
|
|
|
|
|
43790
|
my $c = $head1->content(); |
76
|
544
|
|
|
|
|
9997
|
$c =~ s/.*?-\s*//; |
77
|
544
|
|
|
|
|
86636
|
$c =~ s/\n//g; |
78
|
544
|
|
|
|
|
3365
|
$help->{$n} = $c . " provided by L<$perl_name>"; |
79
|
544
|
|
|
|
|
4089
|
last; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
68
|
|
|
|
|
1645
|
}; |
83
|
|
|
|
|
|
|
|
84
|
68
|
|
|
|
|
6655
|
find ($wanted, $path ) ; |
85
|
|
|
|
|
|
|
|
86
|
68
|
|
|
|
|
186020
|
$self->{help} = $help; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# ABSTRACT: Detect available read/write backends usable by config models |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |